Get PropertyGrid to update?
-
I'm using the propertygrid control to display a small class (the class represents program settings) which contains a System.Drawing.Color, and some other properties. When you click the dropdown next to the color and click a color... everything works fine. The problem is if the user uses the Up and Down keyboard keys to change the color. When they do this the little color preview square next to the name of the color does not update until the Enter key is pressed. I tried just using SendKeys to send Enter when the PropertyValueChanged event fires but unfortunately the control looses focus of the selected property.. which is exactly what happens when the enter key is pressed normally. But it's unnatural because your pressing the down and up keys to scroll through the colors... so ya Enter-key-sending is not the way to go. Is their anyway to force that little color preview box to change to match the color name next to it :-D
-
I'm using the propertygrid control to display a small class (the class represents program settings) which contains a System.Drawing.Color, and some other properties. When you click the dropdown next to the color and click a color... everything works fine. The problem is if the user uses the Up and Down keyboard keys to change the color. When they do this the little color preview square next to the name of the color does not update until the Enter key is pressed. I tried just using SendKeys to send Enter when the PropertyValueChanged event fires but unfortunately the control looses focus of the selected property.. which is exactly what happens when the enter key is pressed normally. But it's unnatural because your pressing the down and up keys to scroll through the colors... so ya Enter-key-sending is not the way to go. Is their anyway to force that little color preview box to change to match the color name next to it :-D
-
I sent the
Tab key
as well after enter and it worked fine for me. There might be a decent way to achieve this that I am not aware of. This way:SendKeys.SendWait("~");
SendKeys.SendWait("{TAB}");जय हिंद
Excellent your code worked perfectly. Here's full code for anyone else that finds this thread.
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SendKeys.Send("{ENTER}~{TAB}");
} -
Excellent your code worked perfectly. Here's full code for anyone else that finds this thread.
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SendKeys.Send("{ENTER}~{TAB}");
}actually this will work to:
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SendKeys.Send("{ENTER}{TAB}");
} -
actually this will work to:
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SendKeys.Send("{ENTER}{TAB}");
} -
FocusedWolf wrote:
SendKeys.Send("{ENTER}{TAB}");
This alone is enough. Actually "~" is just another way to send Enter key.
जय हिंद
Yes you're correct: http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx[^] ENTER key => "{ENTER} or ~"
-
Yes you're correct: http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx[^] ENTER key => "{ENTER} or ~"
Hi , I am usign propertygrid in my application . I am using one class i that i m having " Caption " prooperty. i am I wrote this code to Keyboard UP left,right down keys to work . In that i am having the code to move the controls . according to below condition i am highlighting the property .
Private Sub PropGrid_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropGrid.Enter
fGridEnter = True
End SubPrivate Sub PropGrid_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropGrid.Leave
fGridEnter = False
End SubProtected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean ' IN THIS i am having the code to move the control .
If (keyData = Keys.Down Or keyData = Keys.Up Or keyData = Keys.Left Or keyData = Keys.Right) And fGridEnter Then
PropGrid.SelectedGridItem.Select()Return False
End If
Now the problem is if i am entering caption for textbox then i use Keyboard up, down ,left ,right then Propertygrid is losing the focus . Textbox1.Caption = "ABC DEF " ' Here i amnot able to move the cursor using keyboard keys up, down ,left ,right to change the text of the texbox . How to identify the things ??