473,466 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Which event is raised after a DataGridView sorts itself?

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.
--
Thanks.
Jun 7 '07 #1
7 12630
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

Jun 7 '07 #2
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
Jun 7 '07 #3
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?
--
Thanks.
"Marc Gravell" wrote:
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
Jun 7 '07 #4
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.
--
Thanks.
"Marc Gravell" wrote:
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
Jun 8 '07 #5
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
Jun 8 '07 #6
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.
--
Thanks.
"Marc Gravell" wrote:
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
Jun 8 '07 #7
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.
--
Thanks.
"Marc Gravell" wrote:
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
Jun 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Galina | last post by:
Hello I have an application in MS Access 2000. I have a form, which includes a subform. The subform is based on a table, but locked for any editing. There is Edit button. When clicked, it starts a...
2
by: JollyK | last post by:
Hi friends, This is my question.... From the Page Load event (or Page Init event), I would need to find which event had occurred that caused a PostBack, for example was it a event fired from...
0
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for windows applicatino. Does any one know which event is raised for a Datagridview control when one of the record data is changed and it sorts itself with the default...
1
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I need to hightlight some rows that have new data copied to them after they're sorted. I tried hightlighting int he DragAndDrop event but once the data is copied to some rows and I highlight...
3
nirmalsingh
by: nirmalsingh | last post by:
hai all, i have added a dropdownlist control inside a datagridview by datagridview.controls.add method, now i want fire the event of dropdownlist, but when i try it, event of datagridview is firing....
3
by: Gouri.Mahajan7 | last post by:
Hello, I am new to asp.net. Can anybody please tell me which event is fired when we close the browser. I want to remove some resources when the browser close button is pressed. Thanks in advance....
3
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
In the page_load event i need to see which event fired the post back. what here allows this. I specificly want to know if the enter key was pressed. but i need to check for others. -- (i''ll be...
8
by: pinkfloydfan | last post by:
Hi there I have a form with two TextBoxes each of which has an _Enter event. In each case the _Enter event binds to the same Excel SheetSelectionChange event. What I want to know is: within...
2
by: hnpatel | last post by:
Hi to All, How to use mouse click event for datagridview in c# in vs2005? I m using datagridview in c# application.I had bound data in datagridview.I want to display data in textbox when i...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.