Dynamic panel resize

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kikx
    New Member
    • Aug 2012
    • 8

    Dynamic panel resize

    Hello

    I have a paint program created in C#/GDI, it's supposed to draw shapes or draw with a pen freely (and be able to change pen width and color). So far I have managed to create such a program which draws on a panel using MouseUp/Down/Move events. But there is something I cannot resolve (even though I'll bet it's so simple to solve I'll look stupid), when I maximize the window, the panel is also resized (as I have docked it) but I can only draw on a portion of it which was the same size as the window when the program started (800x400 approx.). I would like to be able to resize the panel along with the window, so that no matter how big the window is I can draw on the whole surface of the panel.

    I hope I have made enough sense.

    Thank you in advance!

    Source code available if needed.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    What type of application are you working with?
    A WinForms application or a WPF application?

    -Frinny

    Comment

    • kikx
      New Member
      • Aug 2012
      • 8

      #3
      It's a winform application.

      Comment

      • Grim
        New Member
        • Aug 2012
        • 2

        #4
        Not sure if it will work, but you should try it.

        Try undocking the panel and resize it programmly when the form being resized.

        Comment

        • PsychoCoder
          Recognized Expert Contributor
          • Jul 2010
          • 465

          #5
          You could always not allow it to be maximized

          Comment

          • kikx
            New Member
            • Aug 2012
            • 8

            #6
            @Grim, using your advice, that would be something to this effect?:

            Code:
            private void Form1_Resize(object sender, EventArgs e)
                    {
                        panel1.Size = new Size(this.Width, this.Height);
                    }

            Comment

            Working...