Datagridview

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
mattys
Posts: 27
Joined: Mon Dec 30, 2019 10:58 am

Datagridview

Post by mattys »

Ive created a datagridview
Im able to import a csv, makes changes, export just fine.
  1. $rows = Import-csv -Path C:\Users\Gino\Documents\receivingTEST.csv
  2.  
  3.     $table = ConvertTo-DataTable -InputObject $rows
  4.  
  5.     Update-DataGridView -DataGridView $datagridview1 -Item $table
Im trying to create preset columns for more functionality, but when I do, the CSV data that is imported is all shifted to the right of Premade columns.
Image
Any help is appreciated.
Attachments
receivingTEST.csv
(177 Bytes) Downloaded 25 times

jvierra
Posts: 14547
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview

Post by jvierra »

You have to add the columns after you import or pre-create all columns matching the names in the CSV,

mattys
Posts: 27
Joined: Mon Dec 30, 2019 10:58 am

Re: Datagridview

Post by mattys »

Thanks for a fast reply.
Ive tried preseting through the designer with a failed attempt
Image

What am I missing?

jvierra
Posts: 14547
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview

Post by jvierra »

You have to make the data name the same as the column name. Just changing the display name won't bind the column to the column.

mattys
Posts: 27
Joined: Mon Dec 30, 2019 10:58 am

Re: Datagridview

Post by mattys »

O wow. I completely missed the 'data property name'

Thank you so much jvierra!

jvierra
Posts: 14547
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview

Post by jvierra »

Yup. I did the same thig the first time I used the DGV.

It is always the best approach to review the online docs for any control you plane to use. It will save you a lot of wasted time.

Locked