1

I have one textboxcolumn and comboboxcolumn in datagridview. I need to change selecteditem when I enter value in TextBoxColumn based on valuemember of comboboxcolumn.

TextBoxColumn- name = itnum
ComboBoxColumn - name = itname

ComboBoxColumn
-------------------------
Value           Display
---------      ----------
  1             Item 1
  2             Item 2 
  3             Item 3
-------------------------

Private Sub GV_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles GV.CellEndEdit
Select Case GV.Columns(e.ColumnIndex).Name
   Case "itnum"
      GV.Item("itname", e.RowIndex).Value = GV.Item("itnum", e.RowIndex).Value
End Select

When I run this code, Error popup like this

enter image description here

My requirement is when I enter 3 in TextBoxCell, ComboBoxCell should automatically change selectedItem to Item 3

Chris
  • 8,527
  • 10
  • 34
  • 51
salih
  • 56
  • 4
  • You should do checks prior to setting GV's value if it's from a text box. Make sure that the value entered into "itnum" is a value already within the GV items set, or you'll need to add it to its items. So, If not comboboxcell.items.contains() then items.add(), then select it. – Kat Sep 30 '14 at 14:58
  • If that doesn't work, make sure you're selecting a value that's a string. I.e. GV.Item("itnum",e.rowindex).value.tostring() – Kat Sep 30 '14 at 14:59

0 Answers0