We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GGC, InsertRow, Set Values into inserted row

Thread ID:

Created:

Updated:

Platform:

Replies:

89763 Sep 4,2009 05:38 PM UTC Sep 14,2009 12:09 PM UTC WinForms 6
loading
Tags: GridControl
Arseny Khutoriansky
Asked On September 4, 2009 05:38 PM UTC

Hi,
I use the GGC associated with the DataTable.
I want to insert a Row into the GGC(and DataTable) by specified index.
Immediately after insertion of a Row I must fill it with values from other specified grid cells.

For example:
DataTable and GGC before insert

-----------------
N | col1 | col2
-----------------
1 | aaaa | bbbb
-----------------
2 | cccc | dddd

And I want insert new row afret row [1], and set value in [col1] from [1][col1], and vaule in [col2] from [2][col2]

-----------------
N | col1 | col2
-----------------
1 | aaaa | bbbb
-----------------
3 | aaaa | dddd
-----------------
2 | cccc | dddd



Could you help how can i do it?

Arseny Khutoriansky
Replied On September 4, 2009 05:42 PM UTC



-----------------
N | col1 | col2
-----------------
1 | aaaa | bbbb
-----------------
3 | aaaa | dddd
-----------------
2 | cccc | dddd

Sorry, this example of result is not correct!

The correct result is:


-----------------
N | col1 | col2
-----------------
1 | aaaa | bbbb
-----------------
2 | aaaa | dddd
-----------------
3 | cccc | dddd



Jisha Joy [Syncfusion]
Replied On September 7, 2009 08:32 AM UTC

Hi Arik,

The GridGroupingControl displays data which is provided by the underlying data source. So to add/remove a record to/from specified location in gridgroupingcontrol, you have to work with the underlying datatable. Please refer to the following code snippets.

//To add a new record at a specific index in grid

DataRow dr = dt.NewRow();
dr["SNo"] = "A100";
dr["StudentID"] = "AS100";
dr["Department"] = "CSE";
dr["Year"] = "I";
dr["Location"] = "City";
dt.Rows.InsertAt(dr, 5);


Sample for you reference:

http://files.syncfusion.com/support/Grid.Windows/F89763.zip

Thank you for using Syncfusion products.

Regards,
Jisha

Arseny Khutoriansky
Replied On September 9, 2009 06:05 AM UTC

Thank you.
I have one more question.
How to highlight any row in the GGC or mark it as selected?

Jisha Joy [Syncfusion]
Replied On September 10, 2009 08:55 AM UTC

Hi Arik,

You could highlight any row in GridGroupingControl when it is selected or clicked by setting the TableOptions.ListBoxSelectionMode property. see the code:
this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One;
Let me know if you have any further queries.

Regards,
Jisha

Arseny Khutoriansky
Replied On September 14, 2009 07:33 AM UTC

Thank you.
But I meant a little more.
This property(TableOptions.ListBoxSelectionMode) I already use.
And I need the following:
The user makes a right-click on any row in the grid, pop up a context menu, user select "Insert Below". Row is inserted, but the cursor (selection) remains on the previous row. But I want the selection moved to the newly inserted row. I have index of inserted row, how do I select it by index?

Jisha Joy [Syncfusion]
Replied On September 14, 2009 12:09 PM UTC

Hi Arik,

You could use the CurrentCell.MoveTo method to move the cursor to the newly inserted row. See the code:


private void menuItem2_Click(object sender, EventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;

DataRow dr = parentTable.NewRow();
dr[0] = 7;
dr[1] = "new";
dr[2] = "new";
parentTable.Rows.InsertAt(dr,cc.RowIndex-2);
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex+1 , cc.ColIndex);
this.gridGroupingControl1.TableControl.CurrentCell.BeginEdit();
}



Please let me know if this helps.

Regards,
Jisha

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;