Datagridview too many rows and auto size

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 7 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
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Datagridview too many rows and auto size

Post by localpct »

I must not be anchoring it correctly or setting a property correctly

Here's my form to make it simpler
SiteSurveyApps.psf
(25.26 KiB) Downloaded 113 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 too many rows and auto size

Post by jvierra »

Anchor on all four sides and it will grow with the form.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Datagridview too many rows and auto size

Post by localpct »

So that was my thinking but it does not :/
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datagridview too many rows and auto size

Post by jvierra »

It works for me. Just anchor to all four sides and run the form then stretch it or shrink it and the grid follows.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Datagridview too many rows and auto size

Post by localpct »

Yes, that does work

I want it to grow automatically based on the size of the data grid

I don't want to resize it myself :P
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datagridview too many rows and auto size

Post by jvierra »

Sorry but I don't understand. The form resizes the grid. The grid cannot resize the form.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Datagridview too many rows and auto size

Post by localpct »

jvierra wrote:Sorry but I don't understand. The form resizes the grid. The grid cannot resize the form.

So there is no way to read the size of the grid and update the size of the form?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datagridview too many rows and auto size

Post by jvierra »

Yes. You can just copy the grid size with adjustments to the forms size.

Form.Width = $gris.Width + $offsetW
Form.Height = $gris.Height + $offsetH
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Datagridview too many rows and auto size

Post by localpct »

perfect!

I know I'm going offtopic here but for the life of me, I cannot figure out this to display only the extra items "chrome, visio, etc..."

$standardapps = Get-Content '\\someshare\projects\SiteSurveyApps-ExcludeList.txt'
$files = Invoke-Command -ComputerName $textbox.text -ScriptBlock {dir C:\Windows\ESD\logs -File} | Select Name | ? {$_ -ne $standardapps }
$files
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datagridview too many rows and auto size

Post by jvierra »

What can't you figure out?

This should be:
$files = Invoke-Command -ComputerName $textbox.text -ScriptBlock {dir C:\Windows\ESD\logs -File} | ? {$standardapps -notcontains $_.Name }
This topic is 7 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