vb 2010 DataGridViewComboBox List Not Dropping Down

Posted on 2011-04-29
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
    LVL 83

    Expert Comment

    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


    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

    Try filling the dt directly using an adapter instead of reader.

    Author Comment

    Thanks, that fixed the problem!
    LVL 83

    Expert Comment

    Glad to help :-)

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    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…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now