472,988 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 software developers and data experts.

DataGridView Combobox Refresh/Update - VB.NET 2.0

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
1 10020
Trey
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

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

Similar topics

0
by: thomasp | last post by:
This is a two part question, 1) The code below should display a form with a datagridview and a few command buttons. This form should allow the user to make change to the records displayed in...
0
by: Wellington Eliel Lopes | last post by:
Hi people, I have a DataGridView with 3 columns of DataGridViewComboboxColumn type. I need select a different value in the first combobox cell and refresh others columns in relation the first...
6
by: George | last post by:
Hi, I have been encountering a refresh problem with DataGridView, which is bound to a DataTable. When I make updates (Add, Delete, update) to the DataGridView, everything flow nicely to...
0
by: lv2compute | last post by:
I am having a problem with my datagridview. I have a small table that has two columns. The first column is bound to my dataset. The second column is a combobox. I add items to the combobox based on...
3
by: David Cartwright | last post by:
Hi all, I'm having a weird time with a call to the Refresh() method of a DataGridView. I have a VB.NET 2005 Windows application with a main form and a "worker" thread. The main form delegates a...
7
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works...
3
by: DEC | last post by:
I have a VB application that's about 95% done. As usual, it's that last 5% that's got me stymied. The program is a Bill-of-material update program that interfaces with an SAP database. The BOM's...
1
by: MFayaz | last post by:
Hello! I have to refresh datagridview when database update , IS there any way to solution that my datagridview auto refresh when any user update database. Thanks in Advance
2
by: YouPoP | last post by:
Hi, I have a Window Form to which i added a datagridview. The binding source is working well, but does not update if the database is modified outside the application (i mean not showing the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.