wiswalld
asked on
Change value in datagridview cell
How can I go to a cell 7 and change its value in a datagridview1 where the value in cell 1 equals the value in datagridview2.
Datagridview1
Unit Date Available
110 4/4/07 No
Datagridview2
Unit Name1 Name2 Cleared
110 Smith Doe 11:00
After I enter a time in the cleared cell of datagridview2 I want the No to change to Yes where Datagridview cell1 = datagridview cell1
Datagridview1
Unit Date Available
110 4/4/07 No
Datagridview2
Unit Name1 Name2 Cleared
110 Smith Doe 11:00
After I enter a time in the cleared cell of datagridview2 I want the No to change to Yes where Datagridview cell1 = datagridview cell1
ASKER
If DataGridView1.Item(columni ndex,rowin dex).Value = DataGridView2.Item(columni ndex,rowin dex).Value then
DataGridView1.Item(columni ndex,rowin dex).Value = "Yes"
End if
I don't know what the row or column index will be. Could be row 10 in datagridview2 and row 3 in datagridview1. I will need to search Datagridview1 column 0 and find the match to Datagridview2 column zero and then update column seven from Datagridview1 where they match.
Unit Date Available
100 4/4/07 Yes
110 4/4/07 No < Row to match>
Datagridview2
Unit Name1 Name2 Cleared
110 Smith Doe 11:00 <Row to match with using 110>
DataGridView1.Item(columni
End if
I don't know what the row or column index will be. Could be row 10 in datagridview2 and row 3 in datagridview1. I will need to search Datagridview1 column 0 and find the match to Datagridview2 column zero and then update column seven from Datagridview1 where they match.
Unit Date Available
100 4/4/07 Yes
110 4/4/07 No < Row to match>
Datagridview2
Unit Name1 Name2 Cleared
110 Smith Doe 11:00 <Row to match with using 110>
ASKER
Something like this maybe:
If Me.Datagridview1("unit").V alue = Me.datagridview2.CurrentRo w.Cells(1) .Value Then
Datagridview1.CurrentRow.C ells(7).Va lue = "Yes"
End If
Error here
Me.Datagridview1("unit").
If Me.Datagridview1("unit").V
Datagridview1.CurrentRow.C
End If
Error here
Me.Datagridview1("unit").
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DataGridView1.Item(columni
End if
where columnindex/rowindex are the indeces of the cell column/row starting from 0. To get the current column/row index, use
DataGridView1.CurrentCell.
DataGridView1.CurrentCell.
YOu can use CellEndEdit event of DataGridView to do this comparation, which is fired right after the cell is finished editing.
Goran