Automatic resizing of the Windows Forms controls

后端 未结 5 599
野性不改
野性不改 2020-12-09 02:12

I\'m using VS2008\'s designer for doing this.

For example if I\'ve a windows form of size say 500x500 and I added a DataGridView to it (490x490).

when I run

相关标签:
5条回答
  • 2020-12-09 02:44

    You can use Dock, or for more precise control use the Anchor property. By setting Anchor to Left, Right, Top, Bottom the control will scale with the window. By setting Anchor to Right the control will move with the right border. By setting Anchor to Top and Bottom the control will scale vertically, but have a fixed width. Just experiment

    0 讨论(0)
  • 2020-12-09 02:45

    If you need other things like textbox , picturebox etc as auto scaling then go to their relevant anchor property and set is according to your desire result.

    0 讨论(0)
  • 2020-12-09 02:52

    for filled up docking inside the winform use:

    dataGridView.Dock = DockStyle.Fill;
    
    0 讨论(0)
  • 2020-12-09 02:59

    Set the Dock property of the DataGridView to Fill.

    0 讨论(0)
  • 2020-12-09 03:00

    You can ether set the Dock-Property of your DataGridView instance to DockStyle.Fill or use the Anchor-Property and set the anchors to:

    dataGridView.Anchor = 
        AnchorStyles.Bottom | 
        AnchorStyles.Right | 
        AnchorStyles.Top | 
        AnchorStyles.Left;
    

    The first method will make your DataGridView to fill your whole client area. The second method will keep the ratio and only resize the control if the container resizes.

    0 讨论(0)
提交回复
热议问题