我对C#Windows窗体文本框有疑问的朋友 [英] Friends I Have A Question About C# Windows Form Textbox
本文介绍了我对C#Windows窗体文本框有疑问的朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框和datagridview我需要当按下文本框中的输入键移动焦点到datagridview cell_select
i have a text box and datagridview i need when press enter key in textbox move focus to datagridview cell_select
推荐答案
没有cell_select
。如果这是你自己的方法或其他成员,这是你的问题。
现在,您需要了解聚焦和选择是两回事。聚焦与键盘焦点无关;整个桌面只有一个聚焦控件。通过调用Control.Focus
来完成聚焦:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.focus(v=vs .110).aspx [ ^ ]。
请注意,只能在当前可见和启用的控件上进行对焦。或者,您可以使用表单的ActiveControl
属性:
https://msdn.microsoft.com/en-us/library/system.windows.forms.containercontrol.activecontrol%28v = vs.110%29.aspx [ ^ ]。
DataGridView中的选择
取决于其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 [ ^ ]。
您可以使用以下选项来选择当前单元格propertySystem.Windows.Forms.DataGridView.CurrentCell
:
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcell% 28v = vs.110%29.aspx [ ^ ]。
参见:https://msdn.microsoft.com/en-us/library/yc4fsbf5%28v=vs.110 %29.aspx [ ^ ]
-SA
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 callingControl.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'sActiveControl
property:
https://msdn.microsoft.com/en-us/library/system.windows.forms.containercontrol.activecontrol%28v=vs.110%29.aspx[^].
Selection inDataGridView
depends on itsSelectionMode
:
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 propertySystem.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
这篇关于我对C#Windows窗体文本框有疑问的朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文