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.
Unfortunately, activation email could not send to your email. Please try again.

Click a row programmatically in a GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

69821 Nov 13,2007 12:09 PM Nov 23,2007 09:44 AM Windows Forms 3
loading
Tags: Grouping
José Manuel
Asked On November 13, 2007 12:09 PM

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

haneefm [Syncfusion]
Replied On November 13, 2007 05:53 PM

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


José Manuel
Replied On November 15, 2007 04:47 PM

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


Fathima Shalini P [Syncfusion]
Replied On November 23, 2007 09:44 AM

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.


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.

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.

;