yraykar Posted October 27, 2003 Posted October 27, 2003 (edited) Problem with dropdownlist (resolved) Hi, I am using combobox with dropdownstyle set to dropdownlist. I am populating the value from table to the combo which is bound. cmbPlant.DataBindings.Clear() cmbPlant.DataSource = l_dvDataView cmbPlant.DisplayMember = "PlantID" cmbPlant.Refresh() l_dvView is a dataview which retreives the plantid. I am trying to set the default value to the text property of combobox as below cmbPlant.SelectedIndex = -1 cmbPlant.Text = l_strHomePlantId cmbPlant.Enabled = False but the value in text property is blank. Please help me Regards yraykar Edited October 28, 2003 by yraykar Quote
Moderators Robby Posted October 27, 2003 Moderators Posted October 27, 2003 Once you bind the combo, you cannot set the text that way, if the value of l_strHomePlantId is already in the combo then you can do a search in the combo and at that point set the SelectedIndex. If the value of l_strHomePlantId doesn't exist and you want to add it to the combo you can use the Insert method to insert it at let's say index zero. Quote Visit...Bassic Software
yraykar Posted October 28, 2003 Author Posted October 28, 2003 Hello Robby, Thanks for the response. It worked thanks again for the help Regards yraykar Quote
Moderators Robby Posted October 29, 2003 Moderators Posted October 29, 2003 yraykar, I am posting your PM here.... posted by yraykar SelectedIndex problem Hello Robby, I am using vs.net 2002 version and developing a project in vb.net. I used the combobox which is bound to the dataview. The combobox is of style DropDownList. I had posted a thread in the forum where i discussed the problem of setting the text value to sonething. The response u sent was to use the search option on the combo box. I used the same as follows to set the selectedindex property. cmbPlant.SelectedIndex = cmbPlant.FindStringExact(l_strHomePlantId) This is working fine here on development machine. If the application is installed on other computer the problem is combobox is blank. Is this a problem in my coding or the problem with version of vb.net i was not able to fig out. Pl help me out in this Regards yraykar Quote Visit...Bassic Software
yraykar Posted October 31, 2003 Author Posted October 31, 2003 .NET Frame work version is different Hi, There is another insight on the same problem. The development machine that is mine is running under the .NET framework version 1.0.3705 and the target machine is having the verion 1.1.432. I don't know whether this is the reason for the above selectedindex problem. Please help me. Regards yraykar Quote
Moderators Robby Posted October 31, 2003 Moderators Posted October 31, 2003 It very well could be but I can't be sure. Perhaps someone else can answer that part. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.