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.

GridListControl: SelectedIndex not set properly

Thread ID:

Created:

Updated:

Platform:

Replies:

77657 Nov 11,2008 11:09 AM Nov 14,2008 05:20 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 11, 2008 11:09 AM

Hi,
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.

Irina






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

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());
Console.WriteLine(this.gridListControl2.SelectedIndex.ToString());
}
}

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.

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.

;