Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Focus on a row in the DataGridView
 

Focus on a row in the DataGridView

I added a row to the DGV.

What are the commands for moving Focus to the new row?

If I want to move focus to another row in the DGV what must I do?

I'm using vb.net primarily and I also know C#.

NetRider  Wednesday, April 19, 2006 3:12 PM
It is just simple:
// C# code:

YourDataGridView.Rows[rowindex].Selected = true;
princealadin  Thursday, April 20, 2006 1:01 PM
It is just simple:
// C# code:

YourDataGridView.Rows[rowindex].Selected = true;
princealadin  Thursday, April 20, 2006 1:01 PM

Thanks, Right On!

NetRider  Thursday, April 20, 2006 3:57 PM

Hi

In the case of editing a cell, this will make a selection but will not focus (ie. put the cursor) on /in the cell for editing.

I cannot find a .focus() method on the Cell object. It would be nice if there was one. Is there a way to set focus on a cell for editing programmatically?

Thanks

badmofo  Thursday, October 05, 2006 1:05 PM
Did you try setting the DataGridView.CurrentCell property?
Matty4242  Thursday, October 05, 2006 1:53 PM

Hi Matty,

Your recommended "Current cell" property is helpful for me. It's quite working and helpful for me.

Can you check the following "Thread" which is related to my problem.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2710215&SiteID=1

My datagridview calculations are after "Cell-Validated" event and moreover the column index number is 7 which is last column of the row. The problem is that when the cell is validated, the cursor is moving to the next row.


If i take button and place the following code, its working fine.

Private sub Button1_Click(...............)
Me.FAR_DetailsDataGridView.CurrentCell = Me.FAR_DetailsDataGridView.Rows(e.RowIndex).Cells(4)
End Sub

One more thing i would like to ask, is there any thinglike referring with columns names to bethe currentcell property instead of using cell(index).


Thanks.
Kashif Chotu


Kashif Chotu  Sunday, January 20, 2008 10:57 AM

You can use google to search for other answers

Custom Search

More Threads

• How to Dock a control in a custom ContainerControl without hiding its custom draw caption at the top?
• Performance
• Inherited forms and the designer (again)
• Background image in form MDI
• CollectionEditor CancelChanges() method
• DataGridView - Edit columns after changing Dataset
• Extender and Panel
• Where do I ask about C# User Controls
• How to Publish latest build of application?
• Switching forms icons