Groups > Microsoft > Windows PowerShell > RE: tablelayoutpanel in powershell




tablelayoutpanel in powershell

tablelayoutpanel in powershell
Tue, 8 Apr 2008 03:30:02 -0700
In powershell I want to use a tablelayoutpanel with 2 rows and 2 columns and 
all rows should have the same size. But the script does't work:

[System.Reflection.Assembly]::LoadWithPartialName("System.windows.Forms&quo
t;)
$form = new-object "System.Windows.Forms.Form"
$form.Size = new-object System.Drawing.Size @(200,200)
$Bereich = new-object "System.Windows.Forms.TableLayoutPanel"
$Bereich.Dock = "Fill"
$Bereich.RowCount = 2
$Bereich.ColumnCount = 2
$Bereich.RowStyles.Add(new RowStyle(SizeType.Percent, 33.33333F))
$form.Controls.Add($Bereich)
$form.showdialog()

Post Reply
Re: tablelayoutpanel in powershell
Wed, 09 Apr 2008 09:00:43 -030
> $Bereich.RowStyles.Add(new RowStyle(SizeType.Percent, 33.33333F))

The oddity seems to be the above line.  I've never used that before. 
I've not spent much time on it, but I'll try to look at it again if 
you're not in a big rush.  It could only be tomorrow night though.

Marco

-- 
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
Post Reply
RE: tablelayoutpanel in powershell
Thu, 10 Apr 2008 12:45:01 -070
Solution:

[System.Reflection.Assembly]::LoadWithPartialName("System.windows.Forms&quo
t;) 
$form = new-object "System.Windows.Forms.Form" 
$form.Size = new-object System.Drawing.Size @(200,200) 
$Bereich = new-object "System.Windows.Forms.TableLayoutPanel" 
$Bereich.Dock = "Fill" 
$Bereich.CellBorderStyle = "Single"
$Bereich.RowCount = 2 
$Bereich.ColumnCount = 2 
$Bereich.RowStyles.Add((new-object 
System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 50)))
$Bereich.RowStyles.Add((new-object 
System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 50)))
$Bereich.ColumnStyles.Add((new-object 
System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 
50)))
$Bereich.ColumnStyles.Add((new-object 
System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 
50)))
$form.Controls.Add($Bereich) 
$form.showdialog() 


"Robert" wrote:

> In powershell I want to use a tablelayoutpanel with 2 rows and 2 columns
and 
> all rows should have the same size. But the script does't work:
> 
>
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.Forms&quo
t;)
> $form = new-object "System.Windows.Forms.Form"
> $form.Size = new-object System.Drawing.Size @(200,200)
> $Bereich = new-object "System.Windows.Forms.TableLayoutPanel"
> $Bereich.Dock = "Fill"
> $Bereich.RowCount = 2
> $Bereich.ColumnCount = 2
> $Bereich.RowStyles.Add(new RowStyle(SizeType.Percent, 33.33333F))
> $form.Controls.Add($Bereich)
> $form.showdialog()
> 
Post Reply
about | contact