Click here to Skip to main content
15,881,812 members
Home / Discussions / C#
   

C#

 
QuestionDeployment with SQL Express 2005 Pin
Searril26-Mar-09 8:54
Searril26-Mar-09 8:54 
AnswerRe: Deployment with SQL Express 2005 Pin
Searril27-Mar-09 1:35
Searril27-Mar-09 1:35 
QuestionOpen drop down list Pin
Chazzysb26-Mar-09 8:52
Chazzysb26-Mar-09 8:52 
AnswerRe: Open drop down list Pin
Jimmanuel26-Mar-09 9:22
Jimmanuel26-Mar-09 9:22 
GeneralRe: Open drop down list Pin
Chazzysb26-Mar-09 10:09
Chazzysb26-Mar-09 10:09 
QuestionCasting socket data to a type Pin
FoxholeWilly26-Mar-09 8:26
FoxholeWilly26-Mar-09 8:26 
AnswerRe: Casting socket data to a type Pin
Eddy Vluggen26-Mar-09 9:26
professionalEddy Vluggen26-Mar-09 9:26 
QuestionListBox Sorting issue (inaccurate) Pin
dfb7826-Mar-09 8:10
dfb7826-Mar-09 8:10 
I am having a problem with sorting a multi-column ListBox. For simplicity, let's say I only have 3 columns: Id, Score, and TotalPoints. I have implemented a Compare method from the IComparer interface that looks like this:

public int Compare(object x, object y)
{
   int compareResult;
   ListViewItem listviewX, listviewY;

   // Cast the objects to be compared to ListViewItem objects
   listviewX = (ListViewItem)x;
   listviewY = (ListViewItem)y;

   // Compare the two items
   compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
   // Calculate correct return value based on object comparison
   if (OrderOfSort == SortOrder.Ascending)
   {
      // Ascending sort is selected, return normal result of compare operation
      return compareResult;
   }
   else if (OrderOfSort == SortOrder.Descending)
   {
      // Descending sort is selected, return negative result of compare operation
      return (-compareResult);
   }
   else
   {
      // Return '0' to indicate they are equal
      return 0;
   }
}


The sorting is inaccurate though. For example, let's say I have 3 rows, and the Scores are 10, 11, and 2. When I sort the column, it displays 10, 11, then 2...not 11, 10, 2. I am pretty sure it has something to do with the number of digits in the string, but I have no idea how to resolve it. For the most part the sorting works, just this little kink. Any help would be greatly appreciated.


Thanks
AnswerRe: ListBox Sorting issue (inaccurate) Pin
Yusuf26-Mar-09 8:54
Yusuf26-Mar-09 8:54 
GeneralRe: ListBox Sorting issue (inaccurate) Pin
dfb7826-Mar-09 9:41
dfb7826-Mar-09 9:41 
AnswerRe: ListBox Sorting issue (inaccurate) Pin
Luc Pattyn26-Mar-09 8:55
sitebuilderLuc Pattyn26-Mar-09 8:55 
Questioncalculator Pin
the exile26-Mar-09 8:04
the exile26-Mar-09 8:04 
AnswerRe: calculator Pin
Eddy Vluggen26-Mar-09 8:08
professionalEddy Vluggen26-Mar-09 8:08 
GeneralRe: calculator Pin
the exile26-Mar-09 8:20
the exile26-Mar-09 8:20 
GeneralRe: calculator Pin
EliottA26-Mar-09 8:48
EliottA26-Mar-09 8:48 
QuestionRe: calculator Pin
CPallini26-Mar-09 8:09
mveCPallini26-Mar-09 8:09 
JokeRe: calculator Pin
Yusuf26-Mar-09 8:50
Yusuf26-Mar-09 8:50 
JokeRe: calculator Pin
CPallini26-Mar-09 9:04
mveCPallini26-Mar-09 9:04 
JokeRe: calculator Pin
0x3c026-Mar-09 9:35
0x3c026-Mar-09 9:35 
AnswerRe: calculator Pin
Roger Wright26-Mar-09 20:04
professionalRoger Wright26-Mar-09 20:04 
AnswerRe: calculator [modified] Pin
Alan Balkany27-Mar-09 3:59
Alan Balkany27-Mar-09 3:59 
Questionhow to use a list array to populate a listbox with columns Pin
robertkjr3d26-Mar-09 7:31
robertkjr3d26-Mar-09 7:31 
AnswerRe: how to use a list array to populate a listbox with columns Pin
dan!sh 26-Mar-09 7:44
professional dan!sh 26-Mar-09 7:44 
GeneralRe: how to use a list array to populate a listbox with columns Pin
robertkjr3d26-Mar-09 7:57
robertkjr3d26-Mar-09 7:57 
GeneralRe: how to use a list array to populate a listbox with columns Pin
dan!sh 26-Mar-09 8:15
professional dan!sh 26-Mar-09 8:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.