|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
simple combo questionI have a combobox. I set Co.ValueMember = "field1" and Co.DisplayMember = "field2" and then load some data this way Co.DataSource = DS.Tables(1) so far so good, I now have a combo filled with data. Now all I need to do is move the combo to an item with code, based on the ValueMember. I guessed something like Co.SelectedValue = "123" No joy. I have loads of other things as well. Any tips? It will help if you tell us what version of .NET you are using as 2.0
has some new methods that will help you in this task, and 1.1 does not... lp Jan http://cwizo.blogspot.com if anyone is interested, I have found the answer to my problem!!!
Co.SelectedValue = "123" does indeed work, However, if you create a new combo at runtime, set the selectedvalue, and then add it to the form, it fails. If you create a new combo at runtime, then add it to the form, then set the selectedvalue, it works fine! Not sure if this is obvious behaviour or not. Oh well, I'll file it under Q for quirky. You can select a item by its value like this:
Me.comboBox.Items.FindByValue(YourValue.ToString()).Selected = True On 27 Apr 2006 14:40:16 -0700, "Tim" <Citizen10Be***@gmail.com> wrote: I belive the drop down list doesn't bind to its data until it's been added to a form. A limitation due to>if anyone is interested, I have found the answer to my problem!!! > >Co.SelectedValue = "123" does indeed work, > >However, if you create a new combo at runtime, set the selectedvalue, >and then add it to the form, it fails. If you create a new combo at >runtime, then add it to the form, then set the selectedvalue, it works >fine! > >Not sure if this is obvious behaviour or not. Oh well, I'll file it >under Q for quirky. BindingContext?
ImageList - Memory-Issue in vs2005
Strange error - help needed VB (5or6) does something wierd with image data how to fill listview without image How to detect removeable drive insertion Enumerating Network connections What happened with module variables? Mabry FTP/NET LicenseKey ! Measuring the degree of sortedness of an array... Detecting microphone |
|||||||||||||||||||||||