Click here to Skip to main content
15,891,939 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i have a text box and datagridview i need when press enter key in textbox move focus to datagridview cell_select
Posted
Comments
ZurdoDev 14-Dec-15 15:11pm    
Where are you stuck?
Sergey Alexandrovich Kryukov 14-Dec-15 15:21pm    
What's wrong with just reading original MSDN documentation? You could find all answers faster.
—SA
Muhammad Qasim Ludin 14-Dec-15 15:21pm    
need for code to create a shortcut when i press that its should move from textbox to datagridview row
BillWoodruff 15-Dec-15 1:15am    
Creating a short-cut is different from parsing the Text in a TextBox and getting a DataGridView Cell address you can use to select a Cell.

Please edit your question to be more clear about what it is you actually want.
Muhammad Qasim Ludin 14-Dec-15 16:45pm    
need for help please

1 solution

There is no such thing as "cell_select". If it's your own method or other member, it's your problem.

Now, you need to understand that focusing and selection are two different things. Focusing is related to keyboard focus and nothing else; there is only one focused control in entire desktop. Focusing is done by calling Control.Focus:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.focus(v=vs.110).aspx[^].

Note that focusing is only possible on currently visible and enabled controls. Alternatively, you can use your form's ActiveControl property:
https://msdn.microsoft.com/en-us/library/system.windows.forms.containercontrol.activecontrol%28v=vs.110%29.aspx[^].

Selection in DataGridView depends on its SelectionMode:
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionmode%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/3c89df86%28v=vs.110%29.aspx[^].

You can select a current cell by using the property System.Windows.Forms.DataGridView.CurrentCell:
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcell%28v=vs.110%29.aspx[^].

See also: https://msdn.microsoft.com/en-us/library/yc4fsbf5%28v=vs.110%29.aspx[^]

—SA
 
Share this answer
 
Comments
BillWoodruff 14-Dec-15 22:57pm    
+5 very thorough

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