Try using System.Windows.Forms.DataGridView instead of System.Windows.Forms.DataGrid.
how to resize columns after loading a table into a datagrid view

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.
thanks!
2 additional answers
Sort by: Most helpful
-
answered
2022-06-28T18:00:32.83+00:00 Daniel Brassard 21 Reputation pointsthe 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
blabla
$data = New-Object System.Windows.Forms.DataGrid
blabla$form.Show()
-
answered
2022-06-28T18:17:37.71+00:00 Daniel Brassard 21 Reputation pointswow, that was easy.
thanks!