How to resize datagridview control when form resizes

前端 未结 12 1353
终归单人心
终归单人心 2020-12-29 18:30

I found a lot of questions about how to resize the form when a child control resizes, but I\'m trying to do something much simpler (maybe so simple people don\'t even ask it

12条回答
  •  抹茶落季
    2020-12-29 19:14

    If anyone else is stuck with this, here's what helped me. Changing the Anchor settings did not work for me. I am using datagridviews within groupboxes in a form which is inside a parent form.

    Handling the form resize event was the only thing that worked for me.

    private void Form1_Resize(object sender, EventArgs e)
    {
         groupBoxSampleQueue.MinimumSize = new Size((this as OperatingForm).Width - 22, 167);
         groupBoxMachineStatus.MinimumSize = new Size((this as OperatingForm).Width - 22, 167);
    }
    

    I added some raw numbers as buffers.

提交回复
热议问题