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.
Locked
User avatar
lontru
Posts: 73
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Fri Aug 18, 2017 4:36 am

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

Post by lontru »

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.
  1. $vendors = Get-ChildItem $SDpath -Directory | Select-Object Name
  2.  
  3. $vendors_table = ConvertTo-DataTable -InputObject $vendors
  4.  
  5. $datagridview_vendors.AutoSizeColumnsMode = 'Fill'
  6.  
  7. $datagridview_vendors.MultiSelect = $false
  8.  
  9. Update-DataGridView -DataGridView $datagridview_vendors -Item $vendors_table -AutoSizeColumns DisplayedCells

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

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

Post by lontru »

Is this the right way?

$datagridview_vendors.RowHeadersVisible = $false

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

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

Post by mxtrinidad »

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

:)

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

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

Post by lontru »

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: 73
Joined: Fri Aug 18, 2017 4:36 am

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

Post by lontru »

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

Would this be the simple and fastest way?
  1. $textbox_SearchVendor_TextChanged={
  2.  
  3. #   NOTE: Make sure you ignore the default watermark text when validating
  4.  
  5.     if($textboxWatermark.Text -eq $textboxWatermark.Tag)
  6.  
  7.     {
  8.  
  9.         $vendors = Get-ChildItem $SDpath -Directory | ? { $_.Name -like "*$($textbox_SearchVendor.Text)*" } | Select-Object Name
  10.  
  11.         $vendors_table = ConvertTo-DataTable -InputObject $vendors
  12.  
  13.         Update-DataGridView -DataGridView $datagridview_vendors -Item $vendors_table -AutoSizeColumns DisplayedCells
  14.  
  15.     }
  16.  
  17. }

Locked