Code Addendum :-)
myArray[count] = Int32.parse(myDv.rows[count]);
________________________________________
From: Peter Ehi [mailto:pehli@xxxxxxxxxxx]
Sent: Monday, December 13, 2004 9:31 PM
To: padnug@xxxxxxxxxxxxxxx
Subject: RE: [padnug] Sorting a Listbox in C#
Kieth,
Looks like your trying to sort an auto increment field from the name i.e.
keyfield which is probably an int. But you?re your code says it's a string
and so sort is sorting on an ASCI value. Try something along these lines.
Int32[] myArray = new Int32[myDv.Rows.count];
Int32 count = 0;
Foreach(DataRowView myDv in myDv.rows)
{
myArray[count] = int.parse("keyField");
count++;
}
I'm sure this has all kinds of syntax errors and I just typed it out real
quick, but the above should show you if your DataView sort now works if you
step through it.
Peter Ehli
________________________________________
From: Keith R. Pinster [mailto:keith.pinster@xxxxxxxxx]
Sent: Monday, December 13, 2004 4:38 PM
To: padnug@xxxxxxxxxxxxxxx
Subject: [padnug] Sorting a Listbox in C#
OK, I must be doing something really stupid. I have a listbox that I
am trying to pupulate from a sorted view, but I can't get it to
work. Here is the code that I'm using:
DataView myDV = new DataView(dsFieldList.Tables[0]);
myDV .Sort = "KeyField";
Listbox1.DisplayMember = "FieldName1";
Listbox1.ValueMember = "KeyField";
Listbox1.DataSource = myDV ;
But my Listbox1 seems to be populated in a random order. What the
heck am I doing wrong?
Thanks
KRP
Yahoo! Groups Sponsor
ADVERTISEMENT
________________________________________
Yahoo! Groups Links
? To visit your group on the web, go to:
http://groups.yahoo.com/group/padnug/
? To unsubscribe from this group, send an email to:
padnug-unsubscribe@xxxxxxxxxxxxxxx
? Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
------------------------ Yahoo! Groups Sponsor --------------------~-->
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~->
|