comboboxcolumn in datagridview

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • noob

    #1

    comboboxcolumn in datagridview

    Hi
    I am having issues with a combobox column in a datagridview with virtual
    mode enabled. I am binding data to both the datagrid and combobox from
    an sql database. Everything works fine however when I select an item in
    the combobox and move onto the next row, the item dissapears from the
    combobox and it moves back to a blank state. I have put a break point
    at: (and it fires off when I click the drop down on the combobox). Can
    anyone suggest a solution.

    Private Sub DataGridView1_E ditingControlSh owing(ByVal sender As
    System.Object, ByVal e As DataGridViewEdi tingControlShow ingEventArgs)
    Handles DataGridView1.E ditingControlSh owing

    Dim editingComboBox As ComboBox = CType(e.Control , ComboBox)
    AddHandler editingComboBox .SelectedIndexC hanged, AddressOf
    Me.editingCombo Box_SelectedInd exChanged

    End Sub
  • Jim Wooley

    #2
    Re: comboboxcolumn in datagridview

    > Hi[color=blue]
    > I am having issues with a combobox column in a datagridview with
    > virtual
    > mode enabled. I am binding data to both the datagrid and combobox from
    > an sql database. Everything works fine however when I select an item
    > in
    > the combobox and move onto the next row, the item dissapears from the
    > combobox and it moves back to a blank state. I have put a break point
    > at: (and it fires off when I click the drop down on the combobox). Can
    > anyone suggest a solution.
    > Private Sub DataGridView1_E ditingControlSh owing(ByVal sender As
    > System.Object, ByVal e As DataGridViewEdi tingControlShow ingEventArgs)
    > Handles DataGridView1.E ditingControlSh owing
    >
    > Dim editingComboBox As ComboBox = CType(e.Control , ComboBox)
    > AddHandler editingComboBox .SelectedIndexC hanged, AddressOf
    > Me.editingCombo Box_SelectedInd exChanged
    > End Sub
    >[/color]

    Where do you remove the handler for the combobox. I suspect that you are
    adding another handler when you move to the next row and not removing the
    handler from the last row, thus both are now handling the same event. Since
    the new row is cleared, it is telling the old row to clear itself. In my
    case, I have just used the native DataGridViewCom boBoxColumn and let the
    standard binding take control. This means that my object is not updated until
    the cell changes focus, but I have resigned myself to that situation at this
    point.

    FWIW, I did run into a problem with disposing the form when the combo box's
    datasource was still bound. I put a solution up at http://devauthority.com/blogs/jwoole...12/02/638.aspx.

    Jim Wooley



    Comment

    Working...