Hi everyone,
I have the current situation, I have get done with the datagridview cellvalidation, but, I need that after the validation get's done, to set different columns values on the same datagridview.

If Vacaciones_HistoricoDataGridView.Columns(e.ColumnIndex).Name = "DataGridViewTextBoxColumn7" Then
            If e.FormattedValue.ToString() > Dias_Asueto Then
                     MsgBox("Los dias correspondientes son " & Dias_Asueto)
                e.Cancel = True
else
'here I was thinking on something like DataGridViewTextBoxColumn7.value = 60 and so on, but none of this works.
   End If
        End If

The event is taking place at the CellValidating event, if anyone can lend me a hand I will really appreciate it, best regards, JJGarc1a

Guys, kind of closing my own threads :S anyway, this is what I found and it works for me...

If Vacaciones_HistoricoDataGridView.Columns(e.ColumnIndex).Name = "DataGridViewTextBoxColumn7" Then
            If e.FormattedValue.ToString() > Dias_Asueto Then
                
                MsgBox("Los dias correspondientes son " & Dias_Asueto)
                e.Cancel = True
            Else
                MsgBox("aqui estoy")
                Me.Vacaciones_HistoricoDataGridView.CurrentRow.Cells("DataGridViewTextBoxColumn8").Value = 20

            End If
        End If

The event is stills take place at the CellValidating event, best regards, JJGarc1a

Hi JJGarcia
I have almost similar problem that you encounter and found the solution.
I am trying to retrieve the data from Excel and fill the DataGridView1 by adding rows into DataGridView then fill it with data retrieve from Excel.

I am desperate for solution and here are my coding:

Private Sub btnFillDGVWithExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillDGVWithExce.click
    
        Dim objExcel As New Excel.Application
        Dim objBook As Excel.Workbook = objExcel.Workbooks.Open(excelPathName)
        Dim objSheet As Excel.Worksheet = objBook.Worksheets(1)
        objExcel.Visible = True
 
        Dim bolFlag As Boolean = True
        Dim excelRow As Integer = 7
        Dim DGVRow As Integer = 1

        Try
            Do While bolFlag = True

                If Convert.ToString(objSheet.Cells(excelRow, 1).value) = "" Then
                    bolFlag = False
                    Exit Do
                End If

                With DataGridView1

                    DataGridView1.Rows.Add()
                    DGVRow += 1
                    excelRow += 1

                    .Rows(DGVRow).Cells(1).Value = objSheet.Cells(excelRow, 1).value  
                    .Rows(DGVRow).Cells(2).Value = objSheet.Cells(excelRow, 2).value   
                    .Rows(DGVRow).Cells(3).Value = objSheet.Cells(excelRow, 3).value  
                    .Rows(DGVRow).Cells(4).Value = objSheet.Cells(excelRow, 4).value  
                    .Rows(DGVRow).Cells(5).Value = objSheet.Cells(excelRow, 5).value  
                    .Rows(DGVRow).Cells(6).Value = objSheet.Cells(excelRow, 6).value   
                    .Rows(DGVRow).Cells(7).Value = objSheet.Cells(excelRow, 7).value   
                    .Rows(DGVRow).Cells(8).Value = objSheet.Cells(excelRow, 8).value  
                    .Rows(DGVRow).Cells(9).Value = objSheet.Cells(excelRow, 9).value             

                End With

            Loop

        Catch ex As Exception
            MessageBox.Show(ex.Message)

        Finally

            objBook.Close()
            objExcel.Quit()
        End Try
    End Sub
This article has been dead for over six months. Start a new discussion instead.