?
Solved

vb net DataGridView ComboBox will not drop down

Posted on 2011-10-27
4
Medium Priority
?
1,092 Views
Last Modified: 2012-05-12
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.

 
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

Open in new window


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
0
Comment
Question by:sqdperu
  • 2
  • 2
4 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 37040637
Is the grid set to allow edits?
0
 

Author Comment

by:sqdperu
ID: 37044086
CodeCrusier,

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).ReadOnly = False

Thanks for the help
0
 

Author Comment

by:sqdperu
ID: 37044101
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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37044525
Glad to help :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question