Good morning. I have a problem with my datagrid when I do automatic row switching. In an invisible column, it shows me an exception: the active cell cannot be set as an invisible cell. Please, what can I do to avoid this?
Public Class Form1 Dim row As Integer Dim column As Integer Dim modeEdition As Boolean Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown If e.KeyCode = Keys.Enter Then row = DataGridView1.CurrentCell.RowIndex column = DataGridView1.CurrentCell.ColumnIndex column += 1 If column = DataGridView1.ColumnCount Then row += 1 If row = DataGridView1.Rows.Count Then If row = DataGridView1.RowCount Then If DataGridView1.DataSource IsNot Nothing Then 'bindingSource1.AddNew() Else DataGridView1.Rows.Add() End If End If End If column = 0 End If DataGridView1.CurrentCell = DataGridView1.Rows(row).Cells(column) e.Handled = True End If End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load DataGridView1.Columns(2).Visible = False End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)