By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,080 Members | 1,748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,080 IT Pros & Developers. It's quick & easy.

Datagridview - Move Focus to a Particular Cell

P: n/a
I am trying to use the bindingnavigator addnewitem button to place the focus
on the first cell in the newrow row. I have disabled the default action and
I am using the bindingnavigatoraddnewitem click event. Using newrowindex for
the row how can I move the focus?
Jul 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>I am trying to use the bindingnavigator addnewitem button to place the
>focus on the first cell in the newrow row. I have disabled the default
action and I am using the bindingnavigatoraddnewitem click event. Using
newrowindex for the row how can I move the focus?
Found it!
DataGridView1.CurrentCell = DataGridView1(0, DataGridView1.NewRowIndex)
Jul 26 '06 #2

P: n/a
Hi,

Here is an example. I added a bindingnaviagator and datagridview to a
form.

Public Class Form1
Dim bs As New BindingSource

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String = _
"Server = .;Database = NorthWind;" & _
"Integrated Security = SSPI;"
Dim conn As New SqlClient.SqlConnection(strConn)
Dim dt1 As New DataTable
Dim da1 As New SqlClient.SqlDataAdapter _
("Select * from Orders", conn)
da1.Fill(dt1)
bs.DataSource = dt1
DataGridView1.DataSource = bs
BindingNavigator1.BindingSource = bs
End Sub

Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BindingNavigatorAddNewItem.Click
bs.AddNew()
bs.Position = bs.Count
End Sub
End Class

Ken
--------------------
"Paul Remblance" <pa**@remblance.co.ukwrote in message
news:4i************@individual.net...
>I am trying to use the bindingnavigator addnewitem button to place the
focus on the first cell in the newrow row. I have disabled the default
action and I am using the bindingnavigatoraddnewitem click event. Using
newrowindex for the row how can I move the focus?

Jul 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.