Click a row programmatically in a GridGroupingControl

Hello,

I use the black triangled arrow (see attachment) in the row header column to mark the current row in a GridGroupingGrid.

The arrow appears when I mouse click any cell in a record or alternateRecord row.

Now I want to make it appear programmatically by code. If I use the CurrencyManager and set its Position property, the arrow doesn't appear.

So I need some code that is identical in behaviour to a mouse click of a cell.

And I need to do it inside CurrencyManager.ListChanged eventHandler, so I must find the cell using no more info than the index of the item in the CurrencyManager, i.e., accessing a cell collection in the grid with the same indexing scheme.

Any help?

Thank you very much.
J.M.



arrow.zip

3 Replies

HA haneefm Syncfusion Team November 13, 2007 10:53 PM UTC

Hi Jose,

You need to call the Record.SetCurrent method to change the CurrencyManager position in a GridGroupingControl.Below is a code :

///set the CurrencyManager's position to first record.
this.gridGroupingControl1.Table.Records[0].SetCurrent();

Best regards,
Haneef



JM José Manuel November 15, 2007 09:47 PM UTC

Hi, Haneef,

I have a problem with your code, because of the event I am capturing.

I use the ListChanged event of the CurrencyManager. This event informs me of a new row in the CurrencyManager, and gives me the e.NewIndex the row will be at.

But, inside this event, the Records collection is not already committed, and in fact, something really strange happens, that I tell next:

If I inspect the Records collection while on the event handler, just before calling SetCurrent, the element in Records at the index e.NewIndex is the new row, replacing the one that existed previously there, which mysteriously has disappeared, but the SetCurrent method, executed there, makes the old row at that index the current row, thus preventing my change.

So, the row at e.NewIndex is the new row for the debugger inside the event handler, but the old row for the SetCurrent method. It seems to be that the grid is in an intermediate state where rows are not committed and grid collections are not to be trusted.

Is there any event, better than the ListChanged event of the CurrencyManager, where I could capture that a new row is added to the grid, and for which your code works to make the black arrow appear in a row programmatically?

Thank you very much.
Jose Manuel



FS Fathima Shalini P Syncfusion Team November 23, 2007 02:44 PM UTC

Hi Jose,

Please do find the simple sample in the following link.

http://websamples.syncfusion.com/samples/Grid.Windows/F%2069298/main.htm

I have used gridGroupingControl1_SourceListListChangedCompleted method. In this sample I have added new records in the datasource and set the it as current cell.

Please do find the code snippet I have used to set the current position.



void gridGroupingControl1_SourceListListChangedCompleted(object sender, Syncfusion.Grouping.TableListChangedEventArgs e)
{
if (e.ListChangedType == ListChangedType.ItemAdded)
{
e.Table.UnsortedRecords[e.NewIndex].SetCurrent("Category");
}
}


Please try this and let me know if this helps.

Regards,
Fathima.


Loader.
Up arrow icon