I am having an issue in powershell 2.0 where I put a border around a scrollable TablePanelLayout. When scrolling there is a border remnant - how do I get this remnant or program such that there is no border remnant when scrolling? Here is the code:
[CmdletBinding()] Param() Set-StrictMode -Version 2 Write-Verbose "Create the main form" $form = New-Object Windows.Forms.Form $form.Size = New-Object Drawing.Size @(900, 400) $form.SuspendLayout() $dataSize = 70 $dataHeight = 20 $volumeSize = 280 Function Create-Data-Panel ($width, $height, $correction) { Write-Verbose "Create the panel that holds the data" $dataPanel = New-Object Windows.Forms.TableLayoutPanel $dataPanel.Size = New-Object Drawing.Size @($width,$height) $dataPanel.Dock = "Fill" $dataPanel.AutoScroll = $true $dataPanel.BackColor = "Transparent" $dataPanel.CellBorderStyle = "None" $dataPanel.RowCount = 0 $dataPanel.ColumnCount = 7 $dataPanel.add_paint({$whitePen = new-object System.Drawing.Pen([system.drawing.color]::blue, 2) $_.graphics.drawrectangle($whitePen,$this.clientrectangle) }) $correctedWidth = $volumeSize - $correction for ($j=0; $j -lt 100; $j++){ for ($i=0; $i -lt 7; $i++) { $label = New-Object System.Windows.Forms.Label $label.TextAlign = "MiddleCenter" $label.Text = "0" $label.Font = "Verdana, 9pt" $label.Size = "$dataSize,$dataHeight" $label.BackColor = "Transparent" if ($i -eq 0) { $label.Size = "$correctedWidth,$dataHeight" $label.Text = "$j 12345678901234567890123456789012" } $dataPanel.Controls.Add($label,$i,$j) } } return $dataPanel } $hght = $form.size.height * 3/4 $statsPanel = Create-Data-Panel 760 60 4 $form.Controls.Add($statsPanel) $form.Add_Shown( { $form.Activate() } ) $form.ResumeLayout() $form.StartPosition = "CenterScreen" $form.ShowDialog()
It appears that this remnant only occurs if you use the scroll slider or the scroll arrows but not if you click on the scroll bar itself to scroll.