本文介绍了将焦点设置为属性网格中的特定属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过使用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




嗨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




嗨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


这篇关于将焦点设置为属性网格中的特定属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 09:16