sqdperu
asked on
vb net DataGridView ComboBox will not drop down
I am using VB.net 2005.
I have a DataGridView with several columns. One of the columns is a ComboBox. What I want to happen is when I populate the DataGridView by binding it with the DataTable I want the ComboBox item that is in the DataTable field to be the one that is shown as selected in the drop down. Then if the user wants to change the value they select a different one from the DropDown (and I will perform some update action). My code displays the correct DataTable item in the ComboBox, but the ComboBox will not drop down so a different item can be selected. What am I doing wrong? Here is the code.
This is the code where I set up the ComboBox in the Form_Load and add all the possible items that can be in the DataTable field.
I then bind the DataGridView to my DataTable and everything populates. The ComboBox column shows the correctly selected item (the value of the Destination field that is in the DataTable), but when I click the drop down arrow nothing happens - it will not drop down to display the values I loaded in the form_load. How do I fix this?
Thanks
I have a DataGridView with several columns. One of the columns is a ComboBox. What I want to happen is when I populate the DataGridView by binding it with the DataTable I want the ComboBox item that is in the DataTable field to be the one that is shown as selected in the drop down. Then if the user wants to change the value they select a different one from the DropDown (and I will perform some update action). My code displays the correct DataTable item in the ComboBox, but the ComboBox will not drop down so a different item can be selected. What am I doing wrong? Here is the code.
This is the code where I set up the ComboBox in the Form_Load and add all the possible items that can be in the DataTable field.
c10 = New DataGridViewComboBoxColumn
c10.Name = "Destination"
c10.DataPropertyName = "Destination"
c10.MaxDropDownItems = 5
c10.Items.Add(" ")
c10.Items.Add("Dane Or Auto")
c10.Items.Add("?")
c10.Items.Add("Manual")
c10.Items.Add("Robo")
c10.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton
Me.dgvQueue.Columns.Add(c10)
' So you only have to click the ComboBox one time to get it to dropdown
Me.dgvQueue.EditMode = DataGridViewEditMode.EditOnEnter
dgvQueue.AutoGenerateColumns = False
I then bind the DataGridView to my DataTable and everything populates. The ComboBox column shows the correctly selected item (the value of the Destination field that is in the DataTable), but when I click the drop down arrow nothing happens - it will not drop down to display the values I loaded in the form_load. How do I fix this?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oops, forgot to add. The grid itself was set tor ReadOnly = False. So I was alright there. It is at the individual cell level where I had it locked down. Thanks.
Glad to help :-)
ASKER
You are correct. I had a copy of a program that I was using to test with and had each columns ReadOnly property set individually as appropriate. I had thought about that. So to fix I had to set the ComboBox column to ReadOnly = False like this:
dgvQueue.Columns(9).ReadOn
Thanks for the help