Which event is raised after a DataGridView sorts itself?

G

Guest

Hi, I'm using vs2005, .net 2, C# for windows application. I have a
DataGridView control that its datasource is from a dataset datatable. After
the user changes the data on a row in the grid, the grid sorts itself based
on the new updated value.

Anyone knows which event is raised after the grid auto-sorts itself? I need
to highlight some rows on the grid after it sorts itsefl. Is this possible?
I tried the grid's Sorts evet and that was not raised.
 
M

Marc Gravell

It is entirely possible that no "sort" is happening here... if the
DataView is simply updating itself, then this could be responding to a
ListChanged event (of type ItemMoved and probably also (separately)
ItemChanged) on the source. Try listening for this event on your
DataView.

Marc
 
M

Marc Gravell

And note; DataView was not a typo... I mean the data-source that you
are binding your DataGridView to; when using a DataTable, this
actually returns a DataView via the IListSource interface. You might
have known this - I am just clarifying.

Marc
 
G

Guest

Marc, Thank you for clarifying that. I'm glad you did because I thought that
was a typo at first. Actually, by code, I created a DtatView and set that as
the datasource of the datagridview control.
I see that thre is an event of ListChanged in the DataView. How do I add
code for an event of that Dataview?
 
G

Guest

Hi Marc,
I was able to add the event for dataview_ListChanged(); However, the data
is updated or changed in the grid by user draging and droping so the
ListChanged event is raised before the drag_drop is completed and the grid's
or the dataview's self-sort is done after the drag_drop event.
 
M

Marc Gravell

I'm really not convinced that the DGV is doing a "self-sort" as you
put it; that is the job of the DataView... in a bound scenario (to a
suitable source, such as a DataView) the DGV doesn't ever do the
sorting - it merely asks the view to sort itself.

Is there no ItemMoved notification? Alternatively, you could force a
reset (somehow - rebind perhaps)?
Can you perhaps hint as to exactly how your drop is adding data?
(there are countless ways of doing this...)

Marc
 
G

Guest

Hi Marc, My bad. I meant to say the Dataview is sorting itself. What you
said makes a lot of sense. I just had a type. Sorry about that.

I'm using the DragDrop of the grid. I now just search through the grid (row
by row) after the DragDrop is completed on the Target grid. All the droped
rows will be marked as mapped in a not visible column named "Mapped". I then
checked for a mapped column (invisible) of each of the grid row and if it's
marked true then I hightlight those rows. I'm just about to try and see if
that work.
 
G

Guest

That seems to be working. I have to loop through all the rows in the grid
and could be a performance issue but I can't seem to have any other way to do
this with better performance though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top