how to resize columns after loading a table into a datagrid view

Daniel Brassard 21 Reputation points

hi all,

I'm loading a datatable with stuff that I display in a datagridview in my GUI.

The table has the correct information, the Datagridview displays it, but the issue is that the columns do not resize themselves to show all of the text, I have only partial values.

How can I change the size of the column programmatically? I do not see any property to allow me that.


Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,407 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. Daniel Brassard 21 Reputation points

    the property AutoSizeColumnsMode exists when I use the GUI tool to create my GUI.

    It does not exists if I create it programmatically.

    $form = New-Object system.Windows.Forms.Form
    $data = New-Object System.Windows.Forms.DataGrid


    0 comments No comments

  2. Daniel Brassard 21 Reputation points

    wow, that was easy.


    0 comments No comments