473,943 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagridview - Move Focus to a Particular Cell

I am trying to use the bindingnavigato r 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 bindingnavigato raddnewitem click event. Using newrowindex for
the row how can I move the focus?
Jul 26 '06 #1
2 14469
>I am trying to use the bindingnavigato r 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 bindingnavigato raddnewitem click event. Using
newrowindex for the row how can I move the focus?
Found it!
DataGridView1.C urrentCell = DataGridView1(0 , DataGridView1.N ewRowIndex)
Jul 26 '06 #2
Hi,

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

Public Class Form1
Dim bs As New BindingSource

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim strConn As String = _
"Server = .;Database = NorthWind;" & _
"Integrated Security = SSPI;"
Dim conn As New SqlClient.SqlCo nnection(strCon n)
Dim dt1 As New DataTable
Dim da1 As New SqlClient.SqlDa taAdapter _
("Select * from Orders", conn)
da1.Fill(dt1)
bs.DataSource = dt1
DataGridView1.D ataSource = bs
BindingNavigato r1.BindingSourc e = bs
End Sub

Private Sub BindingNavigato rAddNewItem_Cli ck(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
BindingNavigato rAddNewItem.Cli ck
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 bindingnavigato r 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 bindingnavigato raddnewitem 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
5626
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 to edit the same last visited cell, focus gets shifted to the first few visible rows as per the dimensions set for the DataGridView. To be exact it goes to the cell in the first row, and the same column. If I can say it this way, I would like...
7
2392
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 events to accomplish this, but I always get: "Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function". A simple example is:
1
3544
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 columns is altered, the calculated columns are only updated when I move to another row. If I move the focus to another cell within the same row, they are not refreshed. What is the best way to force this refresh? Greg
1
2419
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 cell to modify the data (or anything) the entire cell will be selected.
5
20329
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 clicked or tabbed into even though I have set the focus back to the rouge row with a .selected = true property. I have tried the following with no success... iRowNumber = timesheetdataGridView.CurrentCell.RowIndex; DataGridViewRow...
5
7159
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 programmatically into the the underlying cell (i.e., I'm setting Value property of the cell based on user input, but the user is not directly entering any data). The problem:
0
1757
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 edit the same last visited cell, focus gets shifted to the first few visible rows as per the dimensions set for the DataGridView. To be exact it goes to the cell in the first row, and the same column. If I can say it this way, I would like to see...
12
13672
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 display in a textbox below the datgridview. I currently have it fixed so if you click on a row the note field from that row is put in the textbox. I'd like this to be automatic as they move through rows. Also the note field is one of two fields...
0
1609
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 to the next cell. How can I change this behavior when editing the value in a combo box in a DataGridView control?
0
11535
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11126
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10662
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8220
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6309
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.