Expand datagridview proportionally

0

How can I enlarge a datagridview proportionally when the form on which it is located is enlarged? I give examples:

Unlimited

Extended

It would be the difference, without expanding the datagridview is smaller than expanded. When I maximize the program it does not expand and then the datagridview remains in the same size and what I want is for it to get bigger, like the Form1.

Thank you very much and greetings!

    
asked by Adrian Hernando Solanas 12.01.2018 в 22:39
source

2 answers

0

Windows Forms does not have too good mechanisms to handle these types of problems.

What you can do is to recalculate the size of the DataGridView in the events Resize and Shown of the Form.

Something like this:

Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
    ResizeControls()
End Sub

Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
    ResizeControls()
End Sub

Private Sub ResizeControls()
    DataGridView1.Width = Width - 200
    DataGridView1.Height = Height - 150
End Sub
    
answered by 14.01.2018 / 21:00
source
0

Click on the grid and you will see that a triangle appears, expand it and select the option to attach to its container, like the image that I show you.

    
answered by 15.01.2018 в 15:54