Not sure I understand how this will solve the problem. In Visual Studio, if
I design a text box, then highlight it and hit a keyboard character, it will
set focus to the property grid, and enter that character in the "text"
property waiting for more input. Can I recreate this somehow?
Not quite. When I am in Visual Studio designing a form, and I highlight a
text box, when I then hit a letter, such as "T", it moves the cursor to
the
property grid into the text property and enters "T" - then then user can
type the rest of the text in this property. Make sense?
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
Now got it what you desribe in VS. But couldn't associate your aim
with a textbox and typing in a defaul property of a propertygrid
control. For example, you can make a property default by using
"DefaultPropertyAttribute" in your class, for example you can design
your class whose default property is "Title" as follows:
<DefaultPropertyAttribute("Title")> _
Public Class SampleProperty
Private _Title As String
<CategoryAttribute("Application"), _
Browsable(True), _
[ReadOnly](False), _
BindableAttribute(False), _
DefaultValueAttribute(""), _
DesignOnly(False), _
DescriptionAttribute("Enter Title for the application")> _
Public Property Title() As String
Get
Return _Title
End Get
Set(ByVal Value As String)
_Title = Value
End Set
End Property
Now, when you associate that class with PropertyGrid using:
"PropertyGrid1.SelectedObject = New SampleProperty" preferably in
form1_load event, "Title" property is pre-selected in gray and when
you type in a textbox using the code above, it gets focus in blue and
starts to type the value of that property.
Sorry, if i got wrong,
Hope this helps,
Onur Güzel