Changing label text from dataset

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2009
Posts: 23
Reputation: evant8950 is an unknown quantity at this point 
Solved Threads: 0
evant8950 evant8950 is offline Offline
Newbie Poster

Changing label text from dataset

 
0
  #1
Jul 6th, 2009
I have a combo box which is in set to be a drop down list. How do I change the label text based on which ID is selected in the combo box. How do I make the label text change to the corresponding row as the ID?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Changing label text from dataset

 
0
  #2
Jul 6th, 2009
I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 23
Reputation: evant8950 is an unknown quantity at this point 
Solved Threads: 0
evant8950 evant8950 is offline Offline
Newbie Poster

Re: Changing label text from dataset

 
0
  #3
Jul 6th, 2009
Originally Posted by wildgoose View Post
I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.
If I have a list of Names in the dataset and each have an ID and I have a combo box that displays the list of IDs. If I click an ID how to I get the label to show the name corresponding to that ID that was selected from the combobox.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Changing label text from dataset

 
0
  #4
Jul 6th, 2009
You click a listbox or combobox, it returns the index of that item.
You use that index to get the name, or the user data value.

Not the other way around!
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: Changing label text from dataset

 
0
  #5
Jul 6th, 2009
DataRow[] rows = yourTable.Select(string.Format("ID='{0}'",cbIDs.Text));

yourLabel.Text = (string)rows[0]["Name"];
Last edited by JerryShaw; Jul 6th, 2009 at 9:00 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 23
Reputation: evant8950 is an unknown quantity at this point 
Solved Threads: 0
evant8950 evant8950 is offline Offline
Newbie Poster

Re: Changing label text from dataset

 
0
  #6
Jul 6th, 2009
Thanks guys! That should help me.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC