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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Update designer after updating a property

Update designer after updating a property

Scheduled Pinned Locked Moved C#
csshelpquestionannouncement
4 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.
  • C Offline
    C Offline
    Christopher Stratmann
    wrote on last edited by
    #1

    I have a custom control with a custom property. After compiling the project I place my custom control onto a windows form in VS2005. From there I change my custom property on that custom control. The problem is that the custom control doesn't repaint on the designer to show my updated change. The following is the only way I have found to make the control repaint. Invalidate() after _Test = value; doesn't work. I also looked into the System.ComponentModel namespace for something to be placed before public int Test like [Browsable(true)] but didnt find anything. I tried [RefreshProperties(RefreshProperties.Repaint)] but I think that only repaints the properties grid and not the control on the designer. Any ideas???

           private int _Test = 0;
           public int Test
           {
              get { return _Test; }
              set
              {
                 _Test = value;
                 Width--;
                 Width++;
              }
           }
    

    Chris

    S M 2 Replies Last reply
    0
    • C Christopher Stratmann

      I have a custom control with a custom property. After compiling the project I place my custom control onto a windows form in VS2005. From there I change my custom property on that custom control. The problem is that the custom control doesn't repaint on the designer to show my updated change. The following is the only way I have found to make the control repaint. Invalidate() after _Test = value; doesn't work. I also looked into the System.ComponentModel namespace for something to be placed before public int Test like [Browsable(true)] but didnt find anything. I tried [RefreshProperties(RefreshProperties.Repaint)] but I think that only repaints the properties grid and not the control on the designer. Any ideas???

             private int _Test = 0;
             public int Test
             {
                get { return _Test; }
                set
                {
                   _Test = value;
                   Width--;
                   Width++;
                }
             }
      

      Chris

      S Offline
      S Offline
      snorkie
      wrote on last edited by
      #2

      Chris, After using Invalidate(); add the following code. Application.DoEvents(); Once you invalidate the control, windows still has to go and re-paint it. By using the line above, you are telling it to do any events right now. Hogan

      C 1 Reply Last reply
      0
      • S snorkie

        Chris, After using Invalidate(); add the following code. Application.DoEvents(); Once you invalidate the control, windows still has to go and re-paint it. By using the line above, you are telling it to do any events right now. Hogan

        C Offline
        C Offline
        Christopher Stratmann
        wrote on last edited by
        #3

        Ya thanks a lot. It worked great. Chris

        1 Reply Last reply
        0
        • C Christopher Stratmann

          I have a custom control with a custom property. After compiling the project I place my custom control onto a windows form in VS2005. From there I change my custom property on that custom control. The problem is that the custom control doesn't repaint on the designer to show my updated change. The following is the only way I have found to make the control repaint. Invalidate() after _Test = value; doesn't work. I also looked into the System.ComponentModel namespace for something to be placed before public int Test like [Browsable(true)] but didnt find anything. I tried [RefreshProperties(RefreshProperties.Repaint)] but I think that only repaints the properties grid and not the control on the designer. Any ideas???

                 private int _Test = 0;
                 public int Test
                 {
                    get { return _Test; }
                    set
                    {
                       _Test = value;
                       Width--;
                       Width++;
                    }
                 }
          

          Chris

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello, As snorki said befor Invalidate requires DoEvents, to have an emidiate reaction. But DoEvents is not a nice solution as it runs the whole message loop again. I would prefere the Refresh() method. All the best, Martin

          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