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.
This topic is 4 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
mattys
Posts: 62
Last visit: Wed Dec 27, 2023 8:28 am
Has voted: 3 times

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.     $table = ConvertTo-DataTable -InputObject $rows
  3.     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 74 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 62
Last visit: Wed Dec 27, 2023 8:28 am
Has voted: 3 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 62
Last visit: Wed Dec 27, 2023 8:28 am
Has voted: 3 times

Re: Datagridview

Post by mattys »

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

Thank you so much jvierra!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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.
This topic is 4 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked