473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

On Sort Event

Is there an event that is invoked when a user sorts a
column in a Windows Forms DataGrid?

I have context senstive icons that are enabled\disabled
depending upon the selected item in the datagrid. When I
sort the datagrid the selected item changes. I can not
find the event that is fired when the sorting occurrs
therfore I cannot enable\disable the icons

Thanks in advance,
James
Nov 15 '05 #1
3 4066
James,

There is no event to do this with the DataGrid. What you could do is
check the DataView that the grid is bound to at the time you show the
context menu, and then modify it before you show it based on that value. If
the processing is too intensive for that, then I would look at extending the
DataGrid class and handling the windows message for clicking on the
datagrid. If you get a button click, then check to see if it is on a
header, and then check the sort property before and after.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Is there an event that is invoked when a user sorts a
column in a Windows Forms DataGrid?

I have context senstive icons that are enabled\disabled
depending upon the selected item in the datagrid. When I
sort the datagrid the selected item changes. I can not
find the event that is fired when the sorting occurrs
therfore I cannot enable\disable the icons

Thanks in advance,
James

Nov 15 '05 #2
Nick,

I was already using the method you supplied for my
menus. However I also have a toolbar. I enable and
disable some features based on the selected item.

I just found something that appears to be working. The
dataview ListChanged event seems to fire when the sort
button is clicked.

I do have another question.

Is there a way to initialized the sorted column when a
datatable is bound to a dataset. for instance if I knew
the 2nd column was sorted last and I want to refresh the
datagrid from my database I can rebind the datagrid and
set the sort to the 2nd column. It currently gets reset
when I rebind.

James
-----Original Message-----
James,

There is no event to do this with the DataGrid. What you could do ischeck the DataView that the grid is bound to at the time you show thecontext menu, and then modify it before you show it based on that value. Ifthe processing is too intensive for that, then I would look at extending theDataGrid class and handling the windows message for clicking on thedatagrid. If you get a button click, then check to see if it is on aheader, and then check the sort property before and after.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Is there an event that is invoked when a user sorts a
column in a Windows Forms DataGrid?

I have context senstive icons that are enabled\disabled
depending upon the selected item in the datagrid. When I sort the datagrid the selected item changes. I can not
find the event that is fired when the sorting occurrs
therfore I cannot enable\disable the icons

Thanks in advance,
James

.

Nov 15 '05 #3
Never mind I found it DataView.Sort pretty clever how it
works.

-----Original Message-----
Nick,

I was already using the method you supplied for my
menus. However I also have a toolbar. I enable and
disable some features based on the selected item.

I just found something that appears to be working. The
dataview ListChanged event seems to fire when the sort
button is clicked.

I do have another question.

Is there a way to initialized the sorted column when a
datatable is bound to a dataset. for instance if I knew
the 2nd column was sorted last and I want to refresh the
datagrid from my database I can rebind the datagrid and
set the sort to the 2nd column. It currently gets reset
when I rebind.

James
-----Original Message-----
James,

There is no event to do this with the DataGrid.What you could do is
check the DataView that the grid is bound to at the timeyou show the
context menu, and then modify it before you show it

based on that value. If
the processing is too intensive for that, then I would

look at extending the
DataGrid class and handling the windows message for

clicking on the
datagrid. If you get a button click, then check to see

if it is on a
header, and then check the sort property before and

after.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
Is there an event that is invoked when a user sorts a
column in a Windows Forms DataGrid?

I have context senstive icons that are enabled\disabled depending upon the selected item in the datagrid.

When I sort the datagrid the selected item changes. I can not find the event that is fired when the sorting occurrs
therfore I cannot enable\disable the icons

Thanks in advance,
James

.

.

Nov 15 '05 #4

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

Similar topics

0
by: Marco Soul | last post by:
Hello, I am not quite sure how achieve this scenario: I have a data grid with column headers not showing in the grid, rather they're being displayed in a placeholder above the grid as link...
3
by: Ben Helppi via .NET 247 | last post by:
I've been struggling to get functionality out of the DataGrid. The documents that I found weren't any help, so I was wondering if someone could tell me how to find out what Column was pressed on a...
5
by: Kurt Schroeder | last post by:
I'm using VS.net. I have created a component with the basic set of database commands. This component returns a record set that is bound to a datagrid. I want to add a dynamic sort, but am not sure...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
2
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having...
1
by: Fred | last post by:
hi, in my forms i have a few grids w/ sorting, everytime a grid is sorted, i must make new queries to the database to fill all the grids and initialize all the other controls on the page, it`s...
3
by: Thirsty Traveler | last post by:
I have a gridview where the datasource is bound after a selection. The result of doing this is that sorting and paging do not work. I was given a sample of how to resolve this, however my attempt...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
1
by: =?Utf-8?B?VmlkZHM=?= | last post by:
Hi All, I am not able to get the sort event when i EnableViewState =false for data grid. Is there any relation betwn those two.Please comment. How can I get through this problem? Thanks in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...

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.