Setting the focus to a control from the DataGrid

Rohit_Saksena

Member
Joined
Mar 3, 2005
Messages
14
Programming Experience
3-5
Hi All,
My current project has a requirement according to which focus should not traverse within the datagrid, if the datagrid gets clicked by mouse and then on pressing tab focus should go onto the next control.
But this is not happening, I have set the DataGrid as read-only and its tab stop is also False still if I click on it and then press tab it traverses to the next cell within the datagrid (wherein ideally it should get out of the datagrid and should go to the next control).

Can anybody help me out on this issue...I am waiting desperately...

Thanks & Regards
Rohit Saksena
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,335
Location
Sydney, Australia
Programming Experience
10+
I'm not overly experienced with DataGrids, so there may be a better way, but I would suggest using either the KeyDown or KeyPress event handler to test for the Tab key and act accordingly by setting the focus to the next control.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,335
Location
Sydney, Australia
Programming Experience
10+
Further to my previous post, the DataGrid inherits the GetNextControl() Method from the Control class. This allows you to easily find the next control in the tab order.
 
Top Bottom