This project is read-only.

How To : Selection_Changed in datagrid

Oct 14, 2009 at 3:26 PM
Edited Oct 14, 2009 at 10:47 PM

my question is about selection changed events  , it's not an issue ( i think )

the situation is when the first row of the datagrid is selected (selected row index  = 1 ) and you do an operation of filter with a dataview  , a sortColumn of header :

the value of the first cell change but the index of the selection don't change ( so the event is not fired even the value of the row  is changed  )

Have any one a solution ? I can define a function that can be called when the selectionchanged or when the filter changed or when the sort changed  but i think it is a bad concept  !!


Oct 14, 2009 at 6:06 PM

I think everything is ok. DataTable and sourcegrid are two different components, so i think it is ok.

I had similar issue a few years ago, so i took the same approch as you and everything was fine

Oct 14, 2009 at 10:46 PM

Yes you are right , it work well but as performance to do the same work  three times  ?!!

I hope i get an other solution or any idea for better

Thanks for help.

Oct 15, 2009 at 6:14 AM

Well, i am not sure why you have to do the work three times. hope you will find a better solution;)

Oct 16, 2009 at 7:06 AM


I would like to use this topic to ask if it's ok that selectionChanged event is fired several times when new row is selected in datagrid.


void Selection_SelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
   Console.WriteLine("selection changed");


With sourcegrid 4.20 event fires three times, with 4.21beta five times. Am I doing something wrong?

Btw keep up the good work!


Oct 16, 2009 at 8:22 AM

For sourcegrid 4.20  , you are right  but the first selection is for losting selection , the second and the third selection are the same  : repeated twice !

Oct 16, 2009 at 10:26 AM
Edited Oct 16, 2009 at 3:36 PM

I see. Meanwhile I found focusrow works better for my app. I'm using this event to to fill some textboxes with data from grid row when different row is selected.