logo       

Re: Sorting a Listbox in C#: msg#00065

Subject: Re: Sorting a Listbox in C#

Thanks Jeff, but this is doing exactly what my code is doing except 
you're just sorting within the DataView instantiation instead of 
afterwards.

(BTW, not to be too picky or anything, but since the Subject says C# 
and my code below has semi-colons, what does this have to do with 
VB?  Just wondering where you got that from...  ;)  )

KRP

--- In padnug@xxxxxxxxxxxxxxx, "jsbennett425" <jsbennett425@xxxx> 
wrote:
> 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@xxxx] 
> 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.30011
76/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 --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~-> 

 


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