将焦点设置为属性网格中的特定属性 [英] Set Focus To Specific Property In Property Grid
问题描述
我可以通过使用propgrid.Focus将焦点设置到我的属性网格 - 但是我怎样才能设置始终优先的默认属性?
或者只是将焦点设置为
默认属性?可以这样做吗?
I can set focus to my property grid by using propgrid.Focus - but how can I
set the default property that is always first? Or just set focus to the
default property? Can this be done?
推荐答案
9月27日,11:40 * pm,Derek Hart < derekmh ... @ yahoo.comwrote:
On Sep 27, 11:40*pm, "Derek Hart" <derekmh...@yahoo.comwrote:
我可以通过使用propgrid.Focus将焦点设置到我的属性网格 - 但是我怎么能
设置始终是第一个的默认属性?或者只是将焦点设置为
默认属性?可以这样做吗?
I can set focus to my property grid by using propgrid.Focus - but how canI
set the default property that is always first? Or just set focus to the
default property? Can this be done?
嗨Derek,
在PropertyGrid控件中选择(或聚焦)预定义属性
以编程方式,您可以使用循环GridItems并选中label
来确定要选择的项目:
'' - ----开始-----
Dim GridItem As GridItem = PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = GridItem.Parent
对于每个egi作为GridItem在pGridItem.GridItems中
如果egi.Label =" property_label_here"然后
PropertyGrid1.Focus()
egi.Select()
结束如果
下一页
''------结束-------
希望这会有所帮助,
OnurGüzel
Hi Derek,
To select(or focus) a pre-defined property in a PropertyGrid control
programmatically, you can use loop through GridItems and check "label"
to determine which item to be selected:
''------Begin-----
Dim GridItem As GridItem = PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = GridItem.Parent
For Each egi As GridItem In pGridItem.GridItems
If egi.Label = "property_label_here" Then
PropertyGrid1.Focus()
egi.Select()
End If
Next
''------End-------
Hope this helps,
Onur Güzel
谢谢你的回答。只需要添加一件事。我在keydown事件上运行
这个代码用于文本框控件。它现在正确地关注
网格。但是我需要捕获被击中的击键并将其填入
in作为属性中的第一个角色,就像Visual Studio的工作方式一样
当你在控件上时并点击第一个键盘字符,它开始输入该控件的默认属性
。这可能吗?
" kimiraikkonen" < ki ************* @ gmail.comwrote in message
news:d0 ***************** ***************** @ 2g2000hs n.googlegroups.com ...
9月27日晚上11点40分,Derek Hart和< derekmh ... @ yahoo.comwrote:
Thank you for the answer. Just need to add one thing to it. I am running
this code on the keydown event for a textbox control. It sets focus to the
grid properly now. But I need to trap the keystroke that was hit and fill it
in as the first character in the property, just like how Visual Studio works
when you are on a control and hit the first keyboard character and it starts
typing in the default property for that control. Is this possible?
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:d0**********************************@2g2000hs n.googlegroups.com...
On Sep 27, 11:40 pm, "Derek Hart" <derekmh...@yahoo.comwrote:
我可以通过使用propgrid.Focus将焦点设置到我的属性网格 - 但是怎么能
我
设置始终是第一个的默认属性?或者只是将焦点设置为
默认属性?可以这样做吗?
I can set focus to my property grid by using propgrid.Focus - but how can
I
set the default property that is always first? Or just set focus to the
default property? Can this be done?
嗨Derek,
在PropertyGrid控件中选择(或聚焦)预定义属性
以编程方式,您可以使用循环GridItems并选中label
来确定要选择的项目:
'' - ----开始-----
Dim GridItem As GridItem = PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = GridItem.Parent
对于每个egi作为GridItem在pGridItem.GridItems中
如果egi.Label =" property_label_here"然后
PropertyGrid1.Focus()
egi.Select()
结束如果
下一页
''------结束-------
希望这会有所帮助,
OnurGüzel
Hi Derek,
To select(or focus) a pre-defined property in a PropertyGrid control
programmatically, you can use loop through GridItems and check "label"
to determine which item to be selected:
''------Begin-----
Dim GridItem As GridItem = PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = GridItem.Parent
For Each egi As GridItem In pGridItem.GridItems
If egi.Label = "property_label_here" Then
PropertyGrid1.Focus()
egi.Select()
End If
Next
''------End-------
Hope this helps,
Onur Güzel
9月28日,8:33 * pm,Derek Hart和< derekmh ... @ yahoo.comwrote:
On Sep 28, 8:33*pm, "Derek Hart" <derekmh...@yahoo.comwrote:
感谢您的回答。只需要添加一件事。我在keydown事件上运行
这个代码用于文本框控件。它现在正确地关注
网格。但是我需要捕获被击中的击键并填充
in作为属性中的第一个角色,就像Visual Studio在你控制时的工作方式一样工作
点击第一个键盘字符,然后开始输入该控件的默认属性
。这可能吗?
" kimiraikkonen" < kimiraikkone ... @ gmail.com写信息
新闻:d0 *********************** *********** @ 2g2000hs n.googlegroups.com ...
9月27日晚上11点40分,Derek Hart < derekmh ... @ yahoo.comwrote:
Thank you for the answer. Just need to add one thing to it. I am running
this code on the keydown event for a textbox control. It sets focus to the
grid properly now. But I need to trap the keystroke that was hit and fillit
in as the first character in the property, just like how Visual Studio works
when you are on a control and hit the first keyboard character and it starts
typing in the default property for that control. Is this possible?
"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message
news:d0**********************************@2g2000hs n.googlegroups.com...
On Sep 27, 11:40 pm, "Derek Hart" <derekmh...@yahoo.comwrote:
我可以通过使用propgrid.Focus将焦点设置到我的属性网格 - 但是怎么能
我
设置始终是第一个的默认属性?或者只是将焦点设置为
默认属性?可以这样做吗?
I can set focus to my property grid by using propgrid.Focus - but how can
I
set the default property that is always first? Or just set focus to the
default property? Can this be done?
嗨Derek,
在PropertyGrid控件中选择(或聚焦)预定义属性
以编程方式,您可以使用循环GridItems并选中label
来确定要选择的项目:
'' - ----开始-----
Dim GridItem As GridItem = PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = GridItem.Parent
对于每个egi作为GridItem在pGridItem.GridItems中
如果egi.Label =" property_label_here"然后
PropertyGrid1.Focus()
egi.Select()
结束如果
下一页
''------结束-------
希望这会有所帮助,
OnurGüzel
Hi Derek,
To select(or focus) a pre-defined property in a PropertyGrid control
programmatically, you can use loop through GridItems and check "label"
to determine which item to be selected:
''------Begin-----
Dim GridItem As GridItem = PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = GridItem.Parent
For Each egi As GridItem In pGridItem.GridItems
If egi.Label = "property_label_here" Then
PropertyGrid1.Focus()
egi.Select()
End If
Next
''------End-------
Hope this helps,
Onur Güzel
据我所知(我猜不好),你想要像智能感知或设置那样的b $ b
文本框中的属性值,并且在PropertyGrid外部设置PropertyGrid项的值
控制是不可能的,因为值是属性是ReadOnly。
或者,我的另一个猜测,如果你想要突出显示属性网格
项目,它是在PropertyGrid控件内,而初始键匹配
,文本框中的文字你可以使用:
''--------------开始----- --------
Private Sub TextBox1_KeyDown(ByVal sender As System.Object,_
ByVal e As System.Windows.Forms.KeyEventArgs)_
处理TextBox1.KeyDown
Dim GridItem As GridItem = _
PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = _
GridItem.Parent
For Each egi GridItem In _
pGridItem.GridItems
if egi .Label.StartsWith(e.KeyData.ToString)然后
PropertyGrid1.Focus()
egi.Select()
结束如果
下一页
结束子
''--------结束----------
HTH,
OnurGüzel
As far as i understand (i couldn''t guess well maybe), you''re wanting
something like IntelliSense or setting the value of a property within
textbox, and setting PropertyGrid item''s value outside PropertyGrid
control is not possible, because "Value" property is ReadOnly.
Or, my another guess that if you want to highlight a property grid
item which is inside PropertyGrid control while initial key matches
with the text in textbox you can use that:
''--------------Begin-------------
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles TextBox1.KeyDown
Dim GridItem As GridItem = _
PropertyGrid1.SelectedGridItem
Dim pGridItem As GridItem = _
GridItem.Parent
For Each egi As GridItem In _
pGridItem.GridItems
If egi.Label.StartsWith(e.KeyData.ToString) Then
PropertyGrid1.Focus()
egi.Select()
End If
Next
End Sub
''--------End----------
HTH,
Onur Güzel
这篇关于将焦点设置为属性网格中的特定属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!