vb 2010 DataGridViewComboBox List Not Dropping Down

Posted on 2011-04-29
Medium Priority
Last Modified: 2012-05-11
Hello All,

I have a datagridview that has several datagridviewcombobox columns.  I manually configure the columns and then set datasource at runtime.  Each of the comboxbox columns have the numbers 0 to 10 defined in the items collection.  The database would return a number between 0 and 10 to display in that column when the database source is set.  The database grid is set to readonly = false and each of the combobox columns are set to readonly = false, but when I run the program the datagrid throws an error system.argumentexception (i trapped the error after not being able to find a solution) , but now after not having the error displayed the combobox does not drop down to display any values.  I'm assuming that I don't have something configured properly.  Does anyone have any solutions as to what I'm doing wrong?  Thanks for any help.
Question by:rcblevins
  • 3
  • 2
LVL 83

Expert Comment

ID: 35491057
Show us some code otherwise all we can say is that "There seems to be something wrong" and that would not be very useful to you :-)

Author Comment

ID: 35491159

Below is the code.  Please let me know if there is something else you need to see.  Thanks for your help.  

Here is the property values of one of the columns:

        Me.qty.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None
        Me.qty.DataPropertyName = "qty"
        Me.qty.HeaderText = "Q"
        Me.qty.Items.AddRange(New Object() {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"})
        Me.qty.MaxDropDownItems = 11
        Me.qty.Name = "qty"
        Me.qty.Width = 40

and below is the code that sets the datasource (i pass the datagridview and the name of the stored procedure to get the data from to this procedure)

Public Sub FillDataGridView(ByRef CDataGridView As System.Windows.Forms.DataGridView, ByVal commandName As String, ByVal ParamArray Parameters() As String)

        Dim db As New DBHelpers
        Dim tb As New DataTable

        Dim dataGridViewDR As SqlDataReader = db.ExecuteProcedureReturnSqlDR(commandName, Parameters)

        CDataGridView.AutoGenerateColumns = False


        CDataGridView.DataSource = tb



    End Sub
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 35491210
Try filling the dt directly using an adapter instead of reader.

Author Comment

ID: 35491446
Thanks, that fixed the problem!
LVL 83

Expert Comment

ID: 35491459
Glad to help :-)

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 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