logo       

RE: Re: Sorting a Listbox in C#: msg#00068

Subject: RE: Re: Sorting a Listbox in C#
I'm on vacation, so my mind tends to drift...
 
Still, as you insert new rows to your table, the dataview will update the
listview with the proper sequence.  At least, that has been my experience in
the applications I have written.  You may want to reinstantiate the
datasource when a row is added to the table.  This may be what I normally do
(again, out of the office this week) since the data is not bound to the
control the way it can be in say a datagrid control.
 
Give the latter a try.
 
-jeff

  _____  

From: Keith R. Pinster [mailto:keith.pinster@xxxxxxxxx] 
Sent: Tuesday, December 14, 2004 7:55 AM
To: padnug@xxxxxxxxxxxxxxx
Subject: [padnug] 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   

ADVERTISEMENT
 
<http://us.ard.yahoo.com/SIG=1292s0mv2/M=294855.5468653.6549235.3001176/D=gr
oups/S=1705007709:HM/EXP=1103126102/A=2455396/R=0/SIG=119u9qmi7/*http://smal
lbusiness.yahoo.com/domains/> click here        
 
<http://us.adserver.yahoo.com/l?M=294855.5468653.6549235.3001176/D=groups/S=
:HM/A=2455396/rand=849152548>   

  _____  

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>