473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Datagridview - Move Focus to a Particular Cell

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
2 14437
>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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Arvind | last post by:
Hi I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try...
7
by: Bill | last post by:
Column 0 in my unbound DataGridView is read-only. When the user tabs from the last column of a row, I need the focus to go to column 1 of the next row, not column 0. Have tried a wide variety of...
1
by: Greg | last post by:
I'm using a DataGridView object bound to an xml datasource. I have added 2 unbound columns which are populated based on the calculations of data from other columns. When the data in the other...
1
by: Bharathi Kumar | last post by:
Hi, Iam working on a window application using vb.net 2005. There is a control "DataGridView" in vs 2005 instead of data grid control. After binding the datagridview, When we click on any...
5
by: svaradan | last post by:
Hi I have an issue wherein when the RowLeave event is trigerred ina datagridview, I want to set the focus back to the row where the validation failed. But the cell focus goes to the cell i...
5
by: DanThMan | last post by:
The situation: * I have a ButtonColumn in a DataGridView. * When the user preses one of the buttons, a dialog appears. * Based on what the user selects in the dialog, data is entered...
0
by: =?Utf-8?B?S3VtYXIuQS5QLlA=?= | last post by:
I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try to...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
0
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
When I have an editable combobox in a DataGridView and the user tries to correct an error they can not move the cursor from character to character with the arrow keys. The arrow keys move focus...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.