Dear Experts
DataGridView has 3 columns as
Sno----name----marks
While entering data, if sno column is empty and user press Enter or Tab then
Focus must go to me.textbox1
Please help
Dear Experts
DataGridView has 3 columns as
Sno----name----marks
While entering data, if sno column is empty and user press Enter or Tab then
Focus must go to me.textbox1
Please help
Handle the DataGridView1.EditingControlShowing event,
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("No")
dt.Columns.Add("Name")
dt.Rows.Add(1, "A")
dt.Rows.Add(2, "B")
dt.Rows.Add(3, "C")
DataGridView1.DataSource = dt
AddHandler DataGridView1.EditingControlShowing, AddressOf MyEditHandler
End Sub
and from within the handler of EditingControlShowing, handles KeyUp event,
Sub MyEditHandler(ByVal s As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
AddHandler e.Control.KeyUp, AddressOf MyKeyUpHandler
End Sub
Sub MyKeyUpHandler(ByVal s As Object, ByVal e As KeyEventArgs)
If e.KeyCode = Keys.Enter Then
TextBox1.Focus()
End If
End Sub
Sir,
May you did not read the question carefully.
how is about this
While entering data, if sno column is empty and user press Enter or Tab then Focus must go to me.textbox1
You wrote:
Sub MyKeyUpHandler(ByVal s As Object, ByVal e As KeyEventArgs) If e.KeyCode = Keys.Enter Then TextBox1.Focus() End IfEnd SubSub MyKeyUpHandler(ByVal s As Object, ByVal e As KeyEventArgs)
If e.KeyCode = Keys.Enter Then
TextBox1.Focus()
End If
End Sub
How to know that sno columns is empty?
Add the handler for e.Control.Leave event and use CurrentCell.Value property of DataGridView to check the status.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.