Results 1 to 5 of 5

Thread: How to move groupbox?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Location
    Canada right now
    Posts
    15

    How to move groupbox?

    In my application I have certain tasks where I expose a groupbox. Sometimes the groupbox is on top of other controls and I'd like to be able to move it. How is this typically done?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to move groupbox?

    The simple answer is that to move any control you set its Location property. The better answer would be that if you use a FlowLayoutPanel or TableLayoutPanel then your controls should be able to position themselves without any direct intervention from you at run time. If you set up a layout panel properly then hiding and showing controls will cause the entire layout to shuffle itself to accommodate everything properly.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Location
    Canada right now
    Posts
    15

    Re: How to move groupbox?

    I'll need to get my panel away from controls which are not in the panel (primarily instances of a Form2 class). I'm thinking about a mouse drag over a 4 point arrrow graphic on the panel to move it (that is, change its Location property). I just can't figure out how to program that idea.

    I tried putting a picture box on the panel and then wiring-up an event for Picturebox.mousedown but I get the error: Cannot implicitly convert type 'System.EventHandler' to 'System.Windows.Forms.MouseEventHandler'

    I can do it in Flash but I don't know C#.net that well.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to move groupbox?

    I'm afraid your explanation is extremely confusing. Can you try explaining again exactly what you're trying to achieve, step by step, clearly?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Location
    Canada right now
    Posts
    15

    Re: How to move groupbox?

    Sorry,

    In my (Windows Form) application I have a procedure that creates instances of a Form2 class. Form2 holds a fully docked datagrid that displays a matrix. At any time there are several of these in the form1 workspace (mdiparent). The Form2 instances are called "matrix data registers".

    Certain user actions make visible various groupboxes. These boxes control data register maintenance chores. Once in a while these panels are in an awkward position on the form1 workspace.

    I’d like the user to be able to click and hold (mouse down) the mouse button while over a small graphic located on the panel then drag the panel to a new location. It would be something like the technique being used in the Visual Studio development environment for moving groupboxes and other controls (but I don’t need the resize rectangle). The graphic they use is a small square with a horizontal double arrow intersecting a vertical double arrow.

    See http://www.freesoftwaremagazine.com/...4/ss/8move.jpg
    for the graphic.

    Getting the graphic onto the groupbox will of coarse be easy. I am having trouble with creating an event when I mousedown over the graphic. If I could create an event I could write a handler to make the groupbox location agree with the mouse position as it moves.

    Thanks for your patience

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width