Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to set focus on particular cell in datagridview in vb.net
Posted
Comments
Prasad_Kulkarni 12-Mar-12 3:45am    
can you please give some more explanation of your question.
particular cell means??
do you have any condition for that, or anything else. please explain some more..

You can try
Google Results
 
Share this answer
 
Comments
itsureshuk 12-Mar-12 3:56am    
I have Datagridview ...In that cursor is in first column of first row...without entering in that i pressed tab means it moves next column...for that i need to validate the empty space and focus the cursor in same place...help me
uspatel 12-Mar-12 4:00am    
try to change focus on tab index changed event........
hope it can works.......
itsureshuk 12-Mar-12 4:03am    
can you explain briefly
uspatel 12-Mar-12 4:32am    
See SAKryukov answer....
A cell cannot focused. Only a control is a subject of focus. This is a keyboard focus; only one control in all the system can be focused at a time. So a whole data grid can be focused.

As to the cell, if could be selected.

Basically, you need to select a row and a cell in it:
C#
DataGridView myGridView = //...
int rowToSelect = //...
int columnToSelect = //...

DataGridViewRow selectedRow = myGridView.Rows[rowToSelect];
selectedRow.Selected = true;
selectedRow.Cells[columnToSelect].Selected = true;


—SA
 
Share this answer
 
you can set it by assigning current cell

e.g dgv.currentCell = dgv.currenrow.cell("your cell name")

something like that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900