How to resize datagridview control when form resizes

前端 未结 12 1375
终归单人心
终归单人心 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:04

    In your form constructor you could create an event handler like this:

    this.SizeChanged(frm_sizeChanged);
    

    Then create an event handler that resizes the grid appropriately, example:

    private void frm_sizeChanged(object sender, EventArgs e)
    {
         dataGrid.Size = new Size(100, 200);
    }
    

    Replacing those numbers with whatever you'd like.

提交回复
热议问题