473,396 Members | 2,023 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,396 software developers and data experts.

How do I sort the columns (not rows) in a DataGrid?

I have a Windows Forms app in which I have a DataGrid control. I have a
custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat
feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which is
managed by the collection)? Is there a simple process to do this, while
still using my simple class and not resorting to ADO.NET or XML? I would
prefer not to move to ADO.NET or XML, but if it's my only option I'd like to
know.

Jon
Nov 15 '05 #1
11 1326
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all Columns
DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also
their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a
custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat
feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which is managed by the collection)? Is there a simple process to do this, while
still using my simple class and not resorting to ADO.NET or XML? I would
prefer not to move to ADO.NET or XML, but if it's my only option I'd like to know.

Jon

Nov 15 '05 #2
Thanks!

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:ud**************@TK2MSFTNGP11.phx.gbl...
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all Columns DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also
their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a
custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which is
managed by the collection)? Is there a simple process to do this, while
still using my simple class and not resorting to ADO.NET or XML? I would
prefer not to move to ADO.NET or XML, but if it's my only option I'd

like to
know.

Jon


Nov 15 '05 #3
Thanks!

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:ud**************@TK2MSFTNGP11.phx.gbl...
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all Columns DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also
their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a
custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which is
managed by the collection)? Is there a simple process to do this, while
still using my simple class and not resorting to ADO.NET or XML? I would
prefer not to move to ADO.NET or XML, but if it's my only option I'd

like to
know.

Jon


Nov 15 '05 #4
Unfortunately, there is no DataGridTableStyle property in the Windows Forms
DataGrid. There is a TableStyles property, but it is a collection. If I go
MyDataGrid.TableStyles[0].GridColumnStyles.AddRange(new
DataGridColumnStyle[] {.... I don't know what to put here, and
DataGridColumnStyle's constructor is not accessible.

Jon

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks!

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:ud**************@TK2MSFTNGP11.phx.gbl...
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all

Columns
DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also
their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which
is
managed by the collection)? Is there a simple process to do this,

while still using my simple class and not resorting to ADO.NET or XML? I would prefer not to move to ADO.NET or XML, but if it's my only option I'd

like
to
know.

Jon



Nov 15 '05 #5
Unfortunately, there is no DataGridTableStyle property in the Windows Forms
DataGrid. There is a TableStyles property, but it is a collection. If I go
MyDataGrid.TableStyles[0].GridColumnStyles.AddRange(new
DataGridColumnStyle[] {.... I don't know what to put here, and
DataGridColumnStyle's constructor is not accessible.

Jon

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks!

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:ud**************@TK2MSFTNGP11.phx.gbl...
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all

Columns
DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also
their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which
is
managed by the collection)? Is there a simple process to do this,

while still using my simple class and not resorting to ADO.NET or XML? I would prefer not to move to ADO.NET or XML, but if it's my only option I'd

like
to
know.

Jon



Nov 15 '05 #6
In fact, TableStyles[0] fails because there are none.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
Unfortunately, there is no DataGridTableStyle property in the Windows Forms DataGrid. There is a TableStyles property, but it is a collection. If I go
MyDataGrid.TableStyles[0].GridColumnStyles.AddRange(new
DataGridColumnStyle[] {.... I don't know what to put here, and
DataGridColumnStyle's constructor is not accessible.

Jon

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks!

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:ud**************@TK2MSFTNGP11.phx.gbl...
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all Columns
DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I have a Windows Forms app in which I have a DataGrid control. I have a
> custom class that has several properties exposed, and I have made
this > class, or a collection thereof, the DataSource of the DataGrid. This

neat
> feature of the DataGrid allows the properties to be displayed in a
> Collection of this class.
>
> Now, how do I order the columns (not to be confused with the rows,

which is
> managed by the collection)? Is there a simple process to do this, while > still using my simple class and not resorting to ADO.NET or XML? I would > prefer not to move to ADO.NET or XML, but if it's my only option I'd

like
to
> know.
>
> Jon
>
>



Nov 15 '05 #7
In fact, TableStyles[0] fails because there are none.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
Unfortunately, there is no DataGridTableStyle property in the Windows Forms DataGrid. There is a TableStyles property, but it is a collection. If I go
MyDataGrid.TableStyles[0].GridColumnStyles.AddRange(new
DataGridColumnStyle[] {.... I don't know what to put here, and
DataGridColumnStyle's constructor is not accessible.

Jon

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks!

"Zürcher See" <aq****@cannabismail.com> wrote in message
news:ud**************@TK2MSFTNGP11.phx.gbl...
I think you have to set your own DataGridTableStyle:

DataGrid.DataGridTableStyle.GridColumnStyles.Clear (); //Remove all Columns
DataGrid.DataGridTableStyle.GridColumnStyles.AddRa nge(new
DataGrisColumnStyle[]{ .... }); // Set the columns to display and also their order

And add the columns in the order that you want

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I have a Windows Forms app in which I have a DataGrid control. I have a
> custom class that has several properties exposed, and I have made
this > class, or a collection thereof, the DataSource of the DataGrid. This

neat
> feature of the DataGrid allows the properties to be displayed in a
> Collection of this class.
>
> Now, how do I order the columns (not to be confused with the rows,

which is
> managed by the collection)? Is there a simple process to do this, while > still using my simple class and not resorting to ADO.NET or XML? I would > prefer not to move to ADO.NET or XML, but if it's my only option I'd

like
to
> know.
>
> Jon
>
>



Nov 15 '05 #8
Found the answer here.

http://support.microsoft.com/default...;EN-US;Q317383

Jon
Nov 15 '05 #9
Found the answer here.

http://support.microsoft.com/default...;EN-US;Q317383

Jon
Nov 15 '05 #10
Found the answer here:

http://support.microsoft.com/default...b;EN-US;317550

Jon

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a
custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat
feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which is managed by the collection)? Is there a simple process to do this, while
still using my simple class and not resorting to ADO.NET or XML? I would
prefer not to move to ADO.NET or XML, but if it's my only option I'd like to know.

Jon

Nov 15 '05 #11
Found the answer here:

http://support.microsoft.com/default...b;EN-US;317550

Jon

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a Windows Forms app in which I have a DataGrid control. I have a
custom class that has several properties exposed, and I have made this
class, or a collection thereof, the DataSource of the DataGrid. This neat
feature of the DataGrid allows the properties to be displayed in a
Collection of this class.

Now, how do I order the columns (not to be confused with the rows, which is managed by the collection)? Is there a simple process to do this, while
still using my simple class and not resorting to ADO.NET or XML? I would
prefer not to move to ADO.NET or XML, but if it's my only option I'd like to know.

Jon

Nov 15 '05 #12

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

Similar topics

4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
4
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as...
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,...
4
by: Joe | last post by:
Hello, I have a datagrid in an nested html table (one table inside of another table) and have set the allowsSorting property to true. I've created in the code-behind a method (Sub - I'm using...
4
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
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
by: Scott | last post by:
I am trying to sort a datagrid which contains 5 checkbox columns. All other columns sort properly except these 5 checkbox columns which dont sort at all. I am using ASP.NET 1.1 and this code is...
1
by: Aeric | last post by:
I have read the following topic: sorting dataset and I am facing the same issue. I am designing a report. I have fill a dataset with the results from a query. From the results, I used to set...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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
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...

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.