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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridListControl: SelectedIndex not set properly

Thread ID:





77657 Nov 11,2008 04:09 PM UTC Nov 14,2008 10:20 AM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On November 11, 2008 04:09 PM UTC

I am running into strange event issue with GridListControl. I have multicolumn GridListControl placed inside of panel, so it displays grid-like data. To read content of the selected row, I used Grid_SelectionChanged event:

private void Grid_SelectionChanged(object sender, Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs e)
Foo(); //do things here
Foo() method uses myGrid.SelectedIndex and myGrid.SelectedItem properties and I expected that if user selected any row in the grid, they should be filled when event fires.
2 things look strange:
1. when user clicks on the row, Grid_SelectionChanged event fires twice.
2.first time myGrid.SelectedItem if filled but myGrid.SelectedIndex is still set to -1, which causes error in undelying method.
The second time event fires, both properties are set properly.
I used some work around to bypass logic if SelectedIndex=-1,but the question is, if Grid_SelectionChanged really fires AFTER selection happens. And why it is called twice? So far it is not that many things happening, but it may cause performance problem in the future, as we enhance the application. Should we use another event instead? Thanks for your help.
Btw, we use version 4.402, and while I can not confirm it, but it seems that the older version did not have this problem, this code is about 3 years old.


Jisha Joy [Syncfusion]
Replied On November 14, 2008 10:20 AM UTC

Hi Irina,

We appreciate your interest in Syncfusion products. The issue can be solved by checking e.Reason in SelectionChanged event.

void Grid_SelectionChanged(object sender, Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs e)

if (e.Reason == Syncfusion.Windows.Forms.Grid.GridSelectionReason.MouseUp)
Console.WriteLine("Fired" + i.ToString());

Please let me know if this helps.



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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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