4

OK、PowerShell スクリプトを作成し、メイン インターフェイスでタブ付きレイアウトを使用しようとしています。上部のタブを非表示にし、側面のボタンを使用してタブを切り替える以外は、必要なすべての機能を使用できます。側面のボタンで別のタブを選択することに成功しましたが、上部のタブを非表示にする方法がわかりませんか? 誰でもこれを行う方法はありますか???

絵はそれを最もよく言います: ここに画像の説明を入力

参考文献:

  1. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabpage%28v=vs.90%29.aspx
  2. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabpage.tabpagecontrolcollection%28v=vs.90%29.aspx
  3. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabrenderer%28v=vs.90%29.aspx
  4. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol%28v=vs.90%29.aspx

アップデート

このリンク(WinForms Hiding TabControl Headers)が見つかりましたが、Vb.net用です。1時間ほどいじっていますが、今のところうまくいきません >.>

私のコード:

#Generated Form Function
function GenerateForm {

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null

#region Generated Form Objects
$MainMenu = New-Object System.Windows.Forms.Form
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState

#Panels
$Panel1 = New-Object System.Windows.Forms.Panel
$Panel2 = New-Object System.Windows.Forms.Panel

#Buttons
$HomeButton = New-Object System.Windows.Forms.Button
$ScriptSettingsButton = New-Object System.Windows.Forms.Button
$COTSButton = New-Object System.Windows.Forms.Button
$MicrosoftButton = New-Object System.Windows.Forms.Button
$ConfigureButton = New-Object System.Windows.Forms.Button
$MiscToolsButton = New-Object System.Windows.Forms.Button
$TabControl = New-Object System.Windows.Forms.TabControl

#Misc Items
$ProgressBar = New-Object System.Windows.Forms.ProgressBar
$StatusBar = New-Object System.Windows.Forms.StatusBar

#Tabs
$TabControl = New-object System.Windows.Forms.TabControl
$HomeTab = New-Object System.Windows.Forms.TabPage
$ScriptSettingsTab = New-Object System.Windows.Forms.TabPage

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
#Unknown
$handler_MainMenu_Load =
$OnLoadForm_StateCorrection= { $MainMenu.WindowState = $InitialFormWindowState }

#Buttons
$HomeButton_OnClick = { $TabControl.SelectTab($HomeTab) }
$ScriptSettingsButton_OnClick = { $TabControl.SelectTab($ScriptSettingsTab) }
$COTSButton_OnClick = {}
$MicrosoftButton_OnClick = {  }
$ConfigureButton_OnClick = {}
$MiscToolsButton_OnClick = {}

$Hometab.Enabled = 

$statusBar1_PanelClick= 

$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 474
$System_Drawing_Size.Width = 665
$MainMenu.ClientSize = $System_Drawing_Size
$MainMenu.DataBindings.DefaultDataSourceUpdateMode = 0
$MainMenu.Name = "MainMenu"
$MainMenu.Text = "Patching Script"
$MainMenu.TopMost = $True
$MainMenu.add_Load($handler_form1_Load)

# == Home Button == #
$HomeButton.Name = "HomeButton"
$HomeButton.Text = "Home"
$HomeButton.TabIndex = 2
$HomeButton.UseVisualStyleBackColor = $True
$HomeButton.add_Click($HomeButton_OnClick)
$HomeButton.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 69
$HomeButton.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 100
$HomeButton.Size = $System_Drawing_Size

$MainMenu.Controls.Add($HomeButton)

# == Script Settings Button == #
$ScriptSettingsButton.Name = "ScriptSettingsButton"
$ScriptSettingsButton.Text = "Script Settings"
$ScriptSettingsButton.TabIndex = 3
$ScriptSettingsButton.UseVisualStyleBackColor = $True
$ScriptSettingsButton.add_Click($ScriptSettingsButton_OnClick)
$ScriptSettingsButton.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 110
$ScriptSettingsButton.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 100
$ScriptSettingsButton.Size = $System_Drawing_Size

$MainMenu.Controls.Add($ScriptSettingsButton)

# == COTS Button == #
$COTSButton.Name = "COTSButton"
$COTSButton.Text = "C.O.T.S."
$COTSButton.TabIndex = 4
$COTSButton.UseVisualStyleBackColor = $True
$COTSButton.add_Click($COTSButton_OnClick)
$COTSButton.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 151
$COTSButton.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 100
$COTSButton.Size = $System_Drawing_Size

$MainMenu.Controls.Add($COTSButton)

# == Microsoft Button == #
$MicrosoftButton.Name = "MicrosoftButton"
$MicrosoftButton.Text = "Microsoft Patches"
$MicrosoftButton.TabIndex = 5
$MicrosoftButton.UseVisualStyleBackColor = $True
$MicrosoftButton.add_Click($MicrosoftButton_OnClick)
$MicrosoftButton.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 192
$MicrosoftButton.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 100
$MicrosoftButton.Size = $System_Drawing_Size

$MainMenu.Controls.Add($MicrosoftButton)

# == Configure Button == #
$ConfigureButton.Name = "ConfigureButton"
$ConfigureButton.Text = "Configure Script"
$ConfigureButton.TabIndex = 6
$ConfigureButton.Location = $System_Drawing_Point
$ConfigureButton.UseVisualStyleBackColor = $True
$ConfigureButton.add_Click($ConfigureButton_OnClick)
$ConfigureButton.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 233
$ConfigureButton.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 100
$ConfigureButton.Size = $System_Drawing_Size

$MainMenu.Controls.Add($ConfigureButton)

# == Misc Tools Button == #
$MiscToolsButton.Name = "MiscToolsButton"
$MiscToolsButton.Text = "Misc Tools"
$MiscToolsButton.TabIndex = 7
$MiscToolsButton.UseVisualStyleBackColor = $True
$MiscToolsButton.add_Click($MiscToolsButton_OnClick)
$MiscToolsButton.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 274
$MiscToolsButton.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 100
$MiscToolsButton.Size = $System_Drawing_Size

$MainMenu.Controls.Add($MiscToolsButton)

# == Tab Control == #
$TabControl.Name = "TabControl"
$TabControl.TabIndex = 4
$TabControl.SelectedIndex = 0
$TabControl.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 118
$System_Drawing_Point.Y = 70
$TabControl.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 374
$System_Drawing_Size.Width = 535
$TabControl.Size = $System_Drawing_Size

$MainMenu.Controls.Add($TabControl)


# == Home Tab == #
$HomeTab.DataBindings.DefaultDataSourceUpdateMode = 0
$HomeTab.Name = "HomeTab"
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 4
$System_Drawing_Point.Y = 22
$HomeTab.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 205
$System_Drawing_Size.Width = 445
$HomeTab.Size = $System_Drawing_Size
$HomeTab.TabIndex = 2
$HomeTab.Text = "Tab2"
$HomeTab.UseVisualStyleBackColor = $True

$TabControl.Controls.Add($HomeTab)


# == Script Settings Tab == #
$ScriptSettingsTab.DataBindings.DefaultDataSourceUpdateMode = 0
$ScriptSettingsTab.Name = "ScriptSettingsTab"
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 4
$System_Drawing_Point.Y = 22
$ScriptSettingsTab.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 205
$System_Drawing_Size.Width = 445
$ScriptSettingsTab.Size = $System_Drawing_Size
$ScriptSettingsTab.TabIndex = 2
$ScriptSettingsTab.Text = "Tab2"
$ScriptSettingsTab.UseVisualStyleBackColor = $True

$TabControl.Controls.Add($ScriptSettingsTab)

# == Panel 1 == #
#$panel1.DataBindings.DefaultDataSourceUpdateMode = 0
#$System_Drawing_Point = New-Object System.Drawing.Point
#$System_Drawing_Point.X = 118
#$System_Drawing_Point.Y = 70
#$panel1.Location = $System_Drawing_Point
#$panel1.Name = "panel1"
#$System_Drawing_Size = New-Object System.Drawing.Size
#$System_Drawing_Size.Height = 374
#$System_Drawing_Size.Width = 535
#$panel1.Size = $System_Drawing_Size
#$panel1.TabIndex = 8
#$Panel1.BackColor = [System.Drawing.Color]::CornflowerBlue

#$MainMenu.Controls.Add($panel1)

# == Progress Bar == #
$progressBar.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 589
$System_Drawing_Point.Y = 458
$progressBar.Location = $System_Drawing_Point
$progressBar.Name = "progressBar"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 15
$System_Drawing_Size.Width = 75
$progressBar.Size = $System_Drawing_Size
$progressBar.TabIndex = 0

$MainMenu.Controls.Add($progressBar)

# == Status bar == #
$StatusBar.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 456
$StatusBar.Location = $System_Drawing_Point
$StatusBar.Name = "StatusBar"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 18
$System_Drawing_Size.Width = 665
$StatusBar.Size = $System_Drawing_Size
$StatusBar.TabIndex = 1
$StatusBar.Text = "statusBar1"
$StatusBar.add_PanelClick($statusBar_PanelClick)

$MainMenu.Controls.Add($StatusBar)

# == Save and Open Form == #
$InitialFormWindowState = $MainMenu.WindowState
$MainMenu.add_Load($OnLoadForm_StateCorrection)
$MainMenu.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm
4

1 に答える 1

2

以下を TabControl プロパティ設定セクションに追加します。

$TabSizeMode = New-object System.Windows.Forms.TabSizeMode
$TabSizeMode = "Fixed"
$TabControl.SizeMode =$TabSizeMode
$TabControl.ItemSize = New-Object System.Drawing.Size(0, 1)
$TabAppearance = New-object System.Windows.Forms.TabAppearance
$TabAppearance = "Buttons"
$TabControl.Appearance = $TabAppearance

ケビン・デンテのブログより。

タブが正しく切り替わっていることを示すには、次を追加できます。

$HomeTab.BackColor = "White"
$ScriptSettingsTab.BackColor = "Red"
于 2012-12-26T11:53:12.637 に答える