473,503 Members | 9,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to sort a datagrid when clicking on column?

How do I enable my Windows Forms datagrid to sort when I click on the column
header? I have a collection of custom classes that are displayed in my
datagrid, and it works great except for this missing feature! AllowSorting
property is set to True, but it doesn't seem to do anything.

Thanks,
Jon
Nov 15 '05 #1
2 2142
Hi Jon,

Your collection class needs to implement IBindingList so the DataGrid will
know how to sort it. For the details check out this article:

Sorting the Unsortable Collection
http://msdn.microsoft.com/library/de...et01272004.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
How do I enable my Windows Forms datagrid to sort when I click on the column header? I have a collection of custom classes that are displayed in my
datagrid, and it works great except for this missing feature! AllowSorting
property is set to True, but it doesn't seem to do anything.

Thanks,
Jon

Nov 15 '05 #2
Thanks!

Jon

"Rob Windsor [MVP]" <rw******@NO.MORE.SPAM.bigfoot.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
Hi Jon,

Your collection class needs to implement IBindingList so the DataGrid will
know how to sort it. For the details check out this article:

Sorting the Unsortable Collection
http://msdn.microsoft.com/library/de...et01272004.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
How do I enable my Windows Forms datagrid to sort when I click on the

column
header? I have a collection of custom classes that are displayed in my
datagrid, and it works great except for this missing feature! AllowSorting property is set to True, but it doesn't seem to do anything.

Thanks,
Jon


Nov 15 '05 #3

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

Similar topics

14
2033
by: Jack Kaufmann | last post by:
I am trying to verify a datagrid in which there must be an entry in both columns of any new row, and those values must be greater than the corresponding values in the previous row. It is pretty...
3
4073
by: | last post by:
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...
7
2428
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
5
2220
by: Gene Hubert | last post by:
I'm using the DefaultView from the Datasource for a DataGrid to present the data in a particular order. It seems that sorting in this way is an "Active Sort", as is the default sort that is...
1
1444
by: Jim | last post by:
Hello, I am creating a windows form application using vb.net 2003 which displays data in a datagrid, and then, if the user wants, I produce a nicely formatted crystal report of the data. The...
1
5294
by: nate axtell | last post by:
In VB .NET I load the contents of an Excel or comma seperated values file into a dataGrid (via a datatable). One of the columns has a comma in the name of the column. So for the comma separated...
4
2707
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all...
0
619
by: thomasp | last post by:
I have a datagridview that allows the user to sort the column by clicking on the header of the column the user wishes to sort. I did not code this, it had the ability when the datagrid was...
2
2909
by: thomasp | last post by:
I have a datagridview that allows the user to sort the column by clicking on the header of the column the user wishes to sort. I did not code this, it had the ability when the datagrid was...
0
7207
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
7294
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,...
1
7015
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
7470
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...
1
5026
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
3183
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
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.