Relocate control after Maximize form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarwaAlSagheer
    New Member
    • Nov 2008
    • 36

    Relocate control after Maximize form

    hi
    How can we run the app on full-screen. I mean all the controls such as,
    pictureboxe, button on the form would also be re-located when run application at maximize window state

    Currently, when I maximize the form.. controls on the form are not
    relocating.
    How can we do this..
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    attach a handler to one(or more?) of the window size events (resize, resizebegin, resizeend, sizechanged) and recompute where the controls sit

    Comment

    • MarwaAlSagheer
      New Member
      • Nov 2008
      • 36

      #3
      Thanx alot Mr. Plater

      is it posible to solve this problem by using .Net function

      this.ScaleContr ol(new SizeF(15, 30), BoundsSpecified .All);
      If yes please explain how can I do that.

      Comment

      • joedeene
        Contributor
        • Jul 2008
        • 579

        #4
        For your situation when the form is maximized, do you want the controls to get bigger also? If not, you can just use the Control.Dock Property.

        joedeene

        Comment

        • MarwaAlSagheer
          New Member
          • Nov 2008
          • 36

          #5
          The problem was solved by using Scale function for each control with Maximize Scale Factor which calculate by divide size of form in case of maximize over size of form in case of normal .

          Question is this solution need to add about a pixel or 2 for location of control,

          How to can I make it accurate (without adding pixel)?


          Second Question How to prevent editing of Textbox?


          Last Question , when I set text at Textbox and minimize form then return to it again all text at textbox was clear. Do you know why something like this happen ?

          Thanks for advance.

          Comment

          • balabaster
            Recognized Expert Contributor
            • Mar 2007
            • 798

            #6
            You know, you'd think someone would have developed something that would do this by now but I've yet to come across anything useful.

            I tend to use a combination of sizable panels, dockable panels and basic math to complete this task. I create a "RenderCont rol" method that places and sizes my controls according to the form size and then in my load and resize event handlers I call my RenderControl method.

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              To bala: I believe WPF or whatever their latest shebang is does it, I know I had a heck of time placing controls with it.

              As for preventing textbox editing, set the ReadOnly property to true.
              As to why the contents are getting lost, I would say it is something to do with how you handle your resizing.

              Comment

              Working...