[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 448
  • Last Modified:

How do I copy the value from one datagridview cell into another cell in the same row?

This is what I am trying (and failing miserably) to do...

A user has entered a new row in my datagrid. Once they type in a value into the first cell in that row, I want to pre-populate 3 other cells in the row with the same value.

I tried to use the Cell_Leave event and its just raining bombs over here :-(

0
imonfireDAMMIT
Asked:
imonfireDAMMIT
1 Solution
 
nepaluzCommented:
try the cellendedit

    Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
        If e.ColumnIndex = 1 Then
            Me.DataGridView1.Item(2, e.RowIndex).Value = Me.DataGridView1.Item(1, e.RowIndex).Value
            Me.DataGridView1.Item(3, e.RowIndex).Value = Me.DataGridView1.Item(1, e.RowIndex).Value
            Me.DataGridView1.Item(4, e.RowIndex).Value = Me.DataGridView1.Item(1, e.RowIndex).Value
        End If
    End Sub

Open in new window

0
 
imonfireDAMMITAuthor Commented:
Thank YOu  :-) that was extremely helpful. I tweeked the code slightly to fit my particular grid and it worked great!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now