Is it any wonder ...
-
... that new people struggle? A questioner complained that their SortCompare method in a DataGridView did not work. Looking at the code it was clear that they were sorting integer values as strings, which means alphabetic rather than numeric order. So, I went to MSDN to check the documentation, only to discover that OP had copied the code verbatim. And every sample pertaining to sorting in a DataGridView had exactly the same bad code: DataGridViewSortCompareEventArgs Class (System.Windows.Forms) | Microsoft Docs[^].
-
... that new people struggle? A questioner complained that their SortCompare method in a DataGridView did not work. Looking at the code it was clear that they were sorting integer values as strings, which means alphabetic rather than numeric order. So, I went to MSDN to check the documentation, only to discover that OP had copied the code verbatim. And every sample pertaining to sorting in a DataGridView had exactly the same bad code: DataGridViewSortCompareEventArgs Class (System.Windows.Forms) | Microsoft Docs[^].
Richard MacCutchan wrote:
And every sample pertaining to sorting in a DataGridView had exactly the same bad code
At least they are consistent.
-
... that new people struggle? A questioner complained that their SortCompare method in a DataGridView did not work. Looking at the code it was clear that they were sorting integer values as strings, which means alphabetic rather than numeric order. So, I went to MSDN to check the documentation, only to discover that OP had copied the code verbatim. And every sample pertaining to sorting in a DataGridView had exactly the same bad code: DataGridViewSortCompareEventArgs Class (System.Windows.Forms) | Microsoft Docs[^].
-
... that new people struggle? A questioner complained that their SortCompare method in a DataGridView did not work. Looking at the code it was clear that they were sorting integer values as strings, which means alphabetic rather than numeric order. So, I went to MSDN to check the documentation, only to discover that OP had copied the code verbatim. And every sample pertaining to sorting in a DataGridView had exactly the same bad code: DataGridViewSortCompareEventArgs Class (System.Windows.Forms) | Microsoft Docs[^].
Nothing in the docs says that the cells they are comparing contain integers Also directly above the code sample
MSDN
This example is part of a larger example provided in How to: Customize Sorting in the Windows Forms DataGridView Control | Microsoft Docs[^]
The larger example code contains a DataGridView with three string columns.
-
... that new people struggle? A questioner complained that their SortCompare method in a DataGridView did not work. Looking at the code it was clear that they were sorting integer values as strings, which means alphabetic rather than numeric order. So, I went to MSDN to check the documentation, only to discover that OP had copied the code verbatim. And every sample pertaining to sorting in a DataGridView had exactly the same bad code: DataGridViewSortCompareEventArgs Class (System.Windows.Forms) | Microsoft Docs[^].
A plot to flesh out plagiarists?
Technician 1. A person that fixes stuff you can't. 2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge. JaxCoder.com
-
Nothing in the docs says that the cells they are comparing contain integers Also directly above the code sample
MSDN
This example is part of a larger example provided in How to: Customize Sorting in the Windows Forms DataGridView Control | Microsoft Docs[^]
The larger example code contains a DataGridView with three string columns.
Yes, and you understand that. However, the main sample shows the first column labelled "ID" containing numbers (even though as string values). So a relatively inexperienced user would assume that sorting by ID would list numbers 4 and 5 before 11 and 12, rather than the other way round.
-
... that new people struggle? A questioner complained that their SortCompare method in a DataGridView did not work. Looking at the code it was clear that they were sorting integer values as strings, which means alphabetic rather than numeric order. So, I went to MSDN to check the documentation, only to discover that OP had copied the code verbatim. And every sample pertaining to sorting in a DataGridView had exactly the same bad code: DataGridViewSortCompareEventArgs Class (System.Windows.Forms) | Microsoft Docs[^].
Picture implies he wants to number the rows in the gutter. I don't see how sorting is going to help with that :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
Picture implies he wants to number the rows in the gutter. I don't see how sorting is going to help with that :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.