Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by yraykar
  • Moderators
Posted

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.

Visit...Bassic Software
  • Moderators
Posted

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

 

Visit...Bassic Software
Posted

.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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...