' Visual Basic
Public Sub CreateStatusBarPanels()
' Create panels and set text property.
StatusBar1.Panels.Add("One")
StatusBar1.Panels.Add("Two")
StatusBar1.Panels.Add("Three")
' Set properties of StatusBar panels.
' Set AutoSize property of panels.
StatusBar1.Panels(0).AutoSize = StatusBarPanelAutoSize.Spring
StatusBar1.Panels(1).AutoSize = StatusBarPanelAutoSize.Contents
StatusBar1.Panels(2).AutoSize = StatusBarPanelAutoSize.Contents
' Set BorderStyle property of panels.
StatusBar1.Panels(0).BorderStyle = StatusBarPanelBorderStyle.Raised
StatusBar1.Panels(1).BorderStyle = StatusBarPanelBorderStyle.Sunken
StatusBar1.Panels(2).BorderStyle = StatusBarPanelBorderStyle.Raised
' Set Icon property of third panel. You should replace the bolded
' icon in the sample below with an icon of your own choosing.
StatusBar1.Panels(2).Icon = New _
System.Drawing.Icon(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.Personal) _
& "\Icon.ico")
StatusBar1.ShowPanels = True
End Sub
// C#
public void CreateStatusBarPanels()
{
// Create panels and set text property.
statusBar1.Panels.Add("One");
statusBar1.Panels.Add("Two");
statusBar1.Panels.Add("Three");
// Set properties of StatusBar panels.
// Set AutoSize property of panels.
statusBar1.Panels[0].AutoSize = StatusBarPanelAutoSize.Spring;
statusBar1.Panels[1].AutoSize = StatusBarPanelAutoSize.Contents;
statusBar1.Panels[2].AutoSize = StatusBarPanelAutoSize.Contents;
// Set BorderStyle property of panels.
statusBar1.Panels[0].BorderStyle =
StatusBarPanelBorderStyle.Raised;
statusBar1.Panels[1].BorderStyle = StatusBarPanelBorderStyle.Sunken;
statusBar1.Panels[2].BorderStyle = StatusBarPanelBorderStyle.Raised;
// Set Icon property of third panel. You should replace the bolded
// icon in the sample below with an icon of your own choosing.
// Note the escape character used (@) when specifying the path.
statusBar1.Panels[2].Icon =
new System.Drawing.Icon (System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.Personal) _
+ @"\Icon.ico");
statusBar1.ShowPanels = true;
}
// C++
public:
void CreateStatusBarPanels()
{
// Create panels and set text property.
statusBar1->Panels->Add("One");
statusBar1->Panels->Add("Two");
statusBar1->Panels->Add("Three");
// Set properties of StatusBar panels.
// Set AutoSize property of panels.
statusBar1->Panels->Item[0]->AutoSize =
StatusBarPanelAutoSize::Spring;
statusBar1->Panels->Item[1]->AutoSize =
StatusBarPanelAutoSize::Contents;
statusBar1->Panels->Item[2]->AutoSize =
StatusBarPanelAutoSize::Contents;
// Set BorderStyle property of panels.
statusBar1->Panels->Item[0]->BorderStyle =
StatusBarPanelBorderStyle::Raised;
statusBar1->Panels->Item[1]->BorderStyle =
StatusBarPanelBorderStyle::Sunken;
statusBar1->Panels->Item[2]->BorderStyle =
StatusBarPanelBorderStyle::Raised;
// Set Icon property of third panel.
// You should replace the bolded image
// in the sample below with an icon of your own choosing.
statusBar1->Panels->Item[2]->Icon =
new System::Drawing::Icon(String::Concat(
System::Environment::GetFolderPath(
System::Environment::SpecialFolder::Personal),
S"\\Icon.ico"));
statusBar1->ShowPanels = true;
}
这篇博客介绍了如何在Visual Basic、C#和C++中创建StatusBar面板,并设置其自动大小、边框样式以及如何在面板中添加图标。
585

被折叠的 条评论
为什么被折叠?



