datagridview - remove empty row to the left or make it smaller?

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.
Post Reply
User avatar
lontru
Posts: 62
Joined: Fri Aug 18, 2017 4:36 am

datagridview - remove empty row to the left or make it smaller?

Post by lontru » Mon Sep 30, 2019 3:17 am

How do i remove this row or size it smaller? so i can use the space more efficient.
Image

the code i use is below.

Code: Select all

$vendors = Get-ChildItem $SDpath -Directory | Select-Object Name
$vendors_table = ConvertTo-DataTable -InputObject $vendors
$datagridview_vendors.AutoSizeColumnsMode = 'Fill'
$datagridview_vendors.MultiSelect = $false
Update-DataGridView -DataGridView $datagridview_vendors -Item $vendors_table -AutoSizeColumns DisplayedCells

User avatar
lontru
Posts: 62
Joined: Fri Aug 18, 2017 4:36 am

Re: datagridview - remove empty row to the left or make it smaller?

Post by lontru » Mon Sep 30, 2019 4:31 am

Is this the right way?

$datagridview_vendors.RowHeadersVisible = $false

User avatar
mxtrinidad
Site Admin
Posts: 351
Joined: Sun Mar 03, 2013 12:42 pm

Re: datagridview - remove empty row to the left or make it smaller?

Post by mxtrinidad » Mon Sep 30, 2019 5:16 am

You got it!
*.RowHeadersVisible = $false will clear the first column.

:)

User avatar
lontru
Posts: 62
Joined: Fri Aug 18, 2017 4:36 am

Re: datagridview - remove empty row to the left or make it smaller?

Post by lontru » Tue Oct 01, 2019 2:07 am

my next mission is to search in the grid
I will be using a textbox for the input and the result match showed below as i type in the textbox?

how would you code this?

Image

User avatar
lontru
Posts: 62
Joined: Fri Aug 18, 2017 4:36 am

Re: datagridview - remove empty row to the left or make it smaller?

Post by lontru » Tue Oct 01, 2019 2:15 am

my brain is little slow today...did some thinking and came up with this.

Would this be the simple and fastest way?

Code: Select all

$textbox_SearchVendor_TextChanged={
# NOTE: Make sure you ignore the default watermark text when validating
if($textboxWatermark.Text -eq $textboxWatermark.Tag)
{
$vendors = Get-ChildItem $SDpath -Directory | ? { $_.Name -like "*$($textbox_SearchVendor.Text)*" } | Select-Object Name
$vendors_table = ConvertTo-DataTable -InputObject $vendors
Update-DataGridView -DataGridView $datagridview_vendors -Item $vendors_table -AutoSizeColumns DisplayedCells
}
}

Post Reply