VS 2008 [RESOLVED] Datagridview combo column error-VBForums
Results 1 to 3 of 3

Thread: [RESOLVED] Datagridview combo column error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    444

    Resolved [RESOLVED] Datagridview combo column error

    Hi Guys,

    I have a datagridview control in my form. It has a few combo box type columns. What I want is to dynamically populate them ? No databases.

    I am getting error "DataGridViewComboBoxCell value is not valid" when I populate the combo cell values manually.

    For e.g. in DataGridView1_EditingControlShowing event, I wrote :

    If DataGridView1.CurrentCell.ColumnIndex = 1 Then
    Dim combo As ComboBox = CType(e.Control, ComboBox)
    combo.Items.Add("Hello")
    combo.Items.Add("Bye")
    End If

    Next I wanted to write that if value in col 1 is abcd then populate ... values in col 2. But I am getting the same error.

    Can individual cells (combo type) have different values.

    Please let me know what mistake I am making.

    Thank you,

    Cheers,
    GR
    Last edited by greatchap; Mar 9th, 2013 at 06:40 AM.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,369

    Re: Datagridview combo column error

    Yes individual cells can have different values.

    The code you posted works. Could you conjure up code that cause the failure ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    444

    Re: Datagridview combo column error

    I got it. The wrote the code in a new event called CellBeginEdit. plus i made a change Dim combobox As DataGridViewComboBoxCell = Grid1.CurrentCell

    Cheers.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.