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
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
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.
Edited 6 Years Ago by __avd: n/a
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Private Sub btn_addline_Click(ByVal ...