Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Grid View - Sorting a Text Column That Cotains Dashes

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
Does anyone know of a solution for sorting a Data Grid View text column that contains a dash?
This is causing issues because it doesn't match the sort I get from SQL.
I googled some and found somebody that has same issue as me.
The Grid ignores the Dash for sorting.
Is there an option somewhere in .Net that can be set to fix this.

Here is an example.

The Data Grid View sorts like this.e.

10-199
10-299
103-10
103-20
10-399

where I would like:
10-199
10-299
10-399
103-10
103-20


Auguy
Sylvania/Toledo Ohio
 
Odd. I get exactly the result you "would like" in Visual Studio 2019
 
Thanks, this is an old VS 2008 project.
I've been putting off updating to new version, maybe it's time.


Auguy
Sylvania/Toledo Ohio
 
You may also introduce 2 extra columns: FieldA and FieldB

[pre]
FieldX FieldA FieldB
10-199 10 199
10-299 10 299
103-10 103 10
103-20 103 20
10-399 10 399[/pre]

and in your Select statemt add [blue][tt]Order By FieldA, FieldB[/tt][/blue]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top