By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

DataGridView Combobox Refresh/Update - VB.NET 2.0

P: 2
I have an unbound datagridview with three comboboxes (e.g. A, B, C) All three comboboxes share the same datasource and use the same valuemember. If I change the value of say combobox A, then B and C change also.

My problem is that B and C do not show the update until after I click off of combobox A. I want B and C to update as soon as I make the selection on A. How do I do this?

Thanks,
Trey

Expand|Select|Wrap|Line Numbers
  1.  
  2.  Private Sub DataGridView1_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
  3.         If Me.Visible = True Then
  4.             Dim ColumnIndex
  5.  
  6.             ColumnIndex = DataGridView1.CurrentCell.ColumnIndex
  7.  
  8.             If ColumnIndex = 2 Then
  9.                 IndexValue = DataGridView1.CurrentRow.Cells(2).Value
  10.                 DataGridView1.CurrentRow.Cells(3).Value = IndexValue
  11.                 DataGridView1.CurrentRow.Cells(4).Value = IndexValue
  12.             End If
  13.  
  14.             If ColumnIndex = 3 Then
  15.                 IndexValue = DataGridView1.CurrentRow.Cells(3).Value
  16.                 DataGridView1.CurrentRow.Cells(2).Value = IndexValue
  17.                 DataGridView1.CurrentRow.Cells(4).Value = IndexValue
  18.             End If
  19.  
  20.             If ColumnIndex = 4 Then
  21.                 IndexValue = DataGridView1.CurrentRow.Cells(4).Value
  22.                 DataGridView1.CurrentRow.Cells(2).Value = IndexValue
  23.                 DataGridView1.CurrentRow.Cells(3).Value = IndexValue
  24.             End If
  25.  
  26.         Else
  27.             Exit Sub
  28.         End If
  29.  
Oct 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: 2
It has been resolved. The solution was the last event shown starting on line 31.


Expand|Select|Wrap|Line Numbers
  1.  Private Sub DataGridView1_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
  2.         If Me.Visible = True Then
  3.  
  4.             Dim ColumnIndex
  5.  
  6.             ColumnIndex = DataGridView1.CurrentCell.ColumnIndex
  7.  
  8.             If ColumnIndex = 2 Then
  9.                 IndexValue = DataGridView1.CurrentRow.Cells(2).Value
  10.                 DataGridView1.CurrentRow.Cells(3).Value = IndexValue
  11.                 DataGridView1.CurrentRow.Cells(4).Value = IndexValue
  12.             End If
  13.  
  14.             If ColumnIndex = 3 Then
  15.                 IndexValue = DataGridView1.CurrentRow.Cells(3).Value
  16.                 DataGridView1.CurrentRow.Cells(2).Value = IndexValue
  17.                 DataGridView1.CurrentRow.Cells(4).Value = IndexValue
  18.             End If
  19.  
  20.             If ColumnIndex = 4 Then
  21.                 IndexValue = DataGridView1.CurrentRow.Cells(4).Value
  22.                 DataGridView1.CurrentRow.Cells(2).Value = IndexValue
  23.                 DataGridView1.CurrentRow.Cells(3).Value = IndexValue
  24.             End If
  25.  
  26.         Else
  27.             Exit Sub
  28.         End If
  29.     End Sub
  30.  
  31.     Private Sub DataGridView1_CurrentCellDirtyStateChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
  32.         DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
  33.     End Sub
  34.  
Oct 2 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.