logo       

RE: Sorting a Listbox in C#: msg#00062

Subject: RE: Sorting a Listbox in C#
Keith,
 
I don't do VB, but in C# it's...
 
DataView dv = new DataView
    ( dsFieldList.Tables[0]
    , null
    , "KeyField"
    , DataViewRowState.CurrentRows );
 
Listbox1.DataSource = dv;
Listbox1.DataValue = "KeyField";
 
-jeff

  _____  

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
 
<http://us.ard.yahoo.com/SIG=129qqn6k8/M=298184.5639630.6699735.3001176/D=gr
oups/S=1705007709:HM/EXP=1103071098/A=2434971/R=0/SIG=11eeoolb0/*http://www.
netflix.com/Default?mqso=60185400> click here   
 
<http://us.adserver.yahoo.com/l?M=298184.5639630.6699735.3001176/D=groups/S=
:HM/A=2434971/rand=973527676>   

  _____  

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
<mailto:padnug-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe> 
  

*       Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> . 




[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~-> 

 


<Prev in Thread] Current Thread [Next in Thread>