Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get PropertyGrid to update?

Get PropertyGrid to update?

Scheduled Pinned Locked Moved C#
graphicsregexhelpquestionannouncement
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FocusedWolf
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • F FocusedWolf

      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

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      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}");

      जय हिंद

      F 1 Reply Last reply
      0
      • D dan sh

        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}");

        जय हिंद

        F Offline
        F Offline
        FocusedWolf
        wrote on last edited by
        #3

        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}");
        }

        F 1 Reply Last reply
        0
        • F FocusedWolf

          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}");
          }

          F Offline
          F Offline
          FocusedWolf
          wrote on last edited by
          #4

          actually this will work to:

          private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
          {
          SendKeys.Send("{ENTER}{TAB}");
          }

          D 1 Reply Last reply
          0
          • F FocusedWolf

            actually this will work to:

            private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
            {
            SendKeys.Send("{ENTER}{TAB}");
            }

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            FocusedWolf wrote:

            SendKeys.Send("{ENTER}{TAB}");

            This alone is enough. Actually "~" is just another way to send Enter key.

            जय हिंद

            F 1 Reply Last reply
            0
            • D dan sh

              FocusedWolf wrote:

              SendKeys.Send("{ENTER}{TAB}");

              This alone is enough. Actually "~" is just another way to send Enter key.

              जय हिंद

              F Offline
              F Offline
              FocusedWolf
              wrote on last edited by
              #6

              Yes you're correct: http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx[^] ENTER key => "{ENTER} or ~"

              V 1 Reply Last reply
              0
              • F FocusedWolf

                Yes you're correct: http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx[^] ENTER key => "{ENTER} or ~"

                V Offline
                V Offline
                VB 8 0
                wrote on last edited by
                #7

                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 Sub

                Private Sub PropGrid_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropGrid.Leave
                fGridEnter = False
                End Sub

                Protected 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 ??

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups