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.
This topic is 4 years and 5 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
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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. $vendors_table = ConvertTo-DataTable -InputObject $vendors
  3. $datagridview_vendors.AutoSizeColumnsMode = 'Fill'
  4. $datagridview_vendors.MultiSelect = $false
  5. Update-DataGridView -DataGridView $datagridview_vendors -Item $vendors_table -AutoSizeColumns DisplayedCells
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

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: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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. #   NOTE: Make sure you ignore the default watermark text when validating
  3.     if($textboxWatermark.Text -eq $textboxWatermark.Tag)
  4.     {
  5.         $vendors = Get-ChildItem $SDpath -Directory | ? { $_.Name -like "*$($textbox_SearchVendor.Text)*" } | Select-Object Name
  6.         $vendors_table = ConvertTo-DataTable -InputObject $vendors
  7.         Update-DataGridView -DataGridView $datagridview_vendors -Item $vendors_table -AutoSizeColumns DisplayedCells
  8.     }
  9. }
This topic is 4 years and 5 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