locked
Auto resize all fields for full screen RRS feed

  • Question

  • I am very new to visual studio, and i have created winform in vb.net connected to a access database  , when i maximise the form

    only the blank portion is enlarging but the field and my datagridview box is remaining same .

    How to make this re sizeable according my screen size?

     
    Monday, July 20, 2020 10:35 AM

Answers

  • Hello,

    For the DataGridView you can use the following language extension

    Public Module ExtensionMethods
        <Runtime.CompilerServices.Extension()>
        Public Sub ExpandColumns(sender As DataGridView)
            For Each col As DataGridViewColumn In sender.Columns
                col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
            Next
        End Sub
    End Module
    SomeDataGridView.ExpandColumns. As mentioned already, you can make the last column fill available space yet I would not do this but that is your choice. 

    There is no one thing you can do, instead look at Anchor and Dock properties for the controls.

    Also consider using containers such as panels e.g. dock a panel to the bottom of a form, keeping it simple, place a button bottom right corner of the panel, set anchor top, right. Set the DataGridView Dock to Fill. You may need to tinker with things e.g. doing the above might place the DataGridView under the panel so we can fix this by dragging controls around in the Document Outline window e.g.

    In some cases a FlowLayoutPanel might be in order.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Monday, July 20, 2020 10:56 AM

All replies

  • Hi

    Assuming you are using a DataGridView to display the DataTable?

    Maybe setting the column(s) to fill the space?

    Here, a DataGridView called DGV with a column named Item is set to take all available remaining horizontal space.

    DGV.Columns("Item").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill


    Regards Les, Livingston, Scotland


    • Edited by leshay Monday, July 20, 2020 10:52 AM
    Monday, July 20, 2020 10:51 AM
  • Hello,

    For the DataGridView you can use the following language extension

    Public Module ExtensionMethods
        <Runtime.CompilerServices.Extension()>
        Public Sub ExpandColumns(sender As DataGridView)
            For Each col As DataGridViewColumn In sender.Columns
                col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
            Next
        End Sub
    End Module
    SomeDataGridView.ExpandColumns. As mentioned already, you can make the last column fill available space yet I would not do this but that is your choice. 

    There is no one thing you can do, instead look at Anchor and Dock properties for the controls.

    Also consider using containers such as panels e.g. dock a panel to the bottom of a form, keeping it simple, place a button bottom right corner of the panel, set anchor top, right. Set the DataGridView Dock to Fill. You may need to tinker with things e.g. doing the above might place the DataGridView under the panel so we can fix this by dragging controls around in the Document Outline window e.g.

    In some cases a FlowLayoutPanel might be in order.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Monday, July 20, 2020 10:56 AM
  • Thank you so much will try.
    Monday, July 20, 2020 11:11 AM
  • Hi Ravi Kumar12233,

    If your question has been answered then please click the "Mark as Answer" Link at the bottom of the correct post(s), so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao

     

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 30, 2020 8:24 AM