| | |
How do I get around this DataGrid silliness?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 21
Reputation:
Solved Threads: 3
I have a DataGrid bound to a DataTable. For various reasons, I don't want to allow users to sort the data, but I want to sort the data once by "Username" as well as resize the columns.
I use DataTable.DefaultView.Sort = "Username" before binding it to DataGrid.
If I then create a DataGridTableStyle to set column widths for my DataGrid and add it to DataGrid, it overwrites the DataGrid's AllowSorting setting.
If I then set DataGridTableStyle.AllowSorting = False, it reverts back my sorting on DataTable for some reason. This behavior is undocumented and not mentioned anywhere on the web. The AllowSorting from DataGrid doesn't behave this way, so why the silliness? How do I get around it?
I use DataTable.DefaultView.Sort = "Username" before binding it to DataGrid.
If I then create a DataGridTableStyle to set column widths for my DataGrid and add it to DataGrid, it overwrites the DataGrid's AllowSorting setting.
If I then set DataGridTableStyle.AllowSorting = False, it reverts back my sorting on DataTable for some reason. This behavior is undocumented and not mentioned anywhere on the web. The AllowSorting from DataGrid doesn't behave this way, so why the silliness? How do I get around it?
•
•
•
•
I have a DataGrid bound to a DataTable. For various reasons, I don't want to allow users to sort the data, but I want to sort the data once by "Username" as well as resize the columns.
I use DataTable.DefaultView.Sort = "Username" before binding it to DataGrid.
If I then create a DataGridTableStyle to set column widths for my DataGrid and add it to DataGrid, it overwrites the DataGrid's AllowSorting setting.
If I then set DataGridTableStyle.AllowSorting = False, it reverts back my sorting on DataTable for some reason. This behavior is undocumented and not mentioned anywhere on the web. The AllowSorting from DataGrid doesn't behave this way, so why the silliness? How do I get around it?
Reset your datagrid into its original settings then make the sorting on your Query like :
VB.NET Syntax (Toggle Plain Text)
"SELECT username, password FROM your datatable ORDER BY username asc"
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: need help to pass values to array in for loop
- Next Thread: Images
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary box button buttons center click code combo combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder image images isnumericfuntioncall listview login math memory mobile module ms msaccess mssqlbackend mysql navigate net opacity pan peertopeervideostreaming picturebox picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left save savedialog search serial sorting sqldatbase storedprocedure string temp textbox timer updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml





