كيفية القيام بما يلي: الإنضمام إلى ToolStripPanels

يمكنك ربط عناصر تحكم ToolStrip مع ToolStripPanel في وقت التشغيل, وذلك يوفر مرونة تطبيقات واجهة المستندات المتعددة (MDI).

مثال

يوضح مثال التعليمات البرمجية التالي كيفية ضم عناصر تحكم ToolStrip إلى ToolStripPanel.

' Create ToolStripPanel controls.
Dim tspTop As New ToolStripPanel()
Dim tspBottom As New ToolStripPanel()
Dim tspLeft As New ToolStripPanel()
Dim tspRight As New ToolStripPanel()

' Dock the ToolStripPanel controls to the edges of the form.
tspTop.Dock = DockStyle.Top
tspBottom.Dock = DockStyle.Bottom
tspLeft.Dock = DockStyle.Left
tspRight.Dock = DockStyle.Right

' Create ToolStrip controls to move among the 
' ToolStripPanel controls.
' Create the "Top" ToolStrip control and add
' to the corresponding ToolStripPanel.
Dim tsTop As New ToolStrip()
tsTop.Items.Add("Top")
tspTop.Join(tsTop)

' Create the "Bottom" ToolStrip control and add
' to the corresponding ToolStripPanel.
Dim tsBottom As New ToolStrip()
tsBottom.Items.Add("Bottom")
tspBottom.Join(tsBottom)

' Create the "Right" ToolStrip control and add
' to the corresponding ToolStripPanel.
Dim tsRight As New ToolStrip()
tsRight.Items.Add("Right")
tspRight.Join(tsRight)

' Create the "Left" ToolStrip control and add
' to the corresponding ToolStripPanel.
Dim tsLeft As New ToolStrip()
tsLeft.Items.Add("Left")
tspLeft.Join(tsLeft)
// Create ToolStripPanel controls.
ToolStripPanel tspTop = new ToolStripPanel();
ToolStripPanel tspBottom = new ToolStripPanel();
ToolStripPanel tspLeft = new ToolStripPanel();
ToolStripPanel tspRight = new ToolStripPanel();

// Dock the ToolStripPanel controls to the edges of the form.
tspTop.Dock = DockStyle.Top;
tspBottom.Dock = DockStyle.Bottom;
tspLeft.Dock = DockStyle.Left;
tspRight.Dock = DockStyle.Right;

// Create ToolStrip controls to move among the 
// ToolStripPanel controls.

// Create the "Top" ToolStrip control and add
// to the corresponding ToolStripPanel.
ToolStrip tsTop = new ToolStrip();
tsTop.Items.Add("Top");
tspTop.Join(tsTop);

// Create the "Bottom" ToolStrip control and add
// to the corresponding ToolStripPanel.
ToolStrip tsBottom = new ToolStrip();
tsBottom.Items.Add("Bottom");
tspBottom.Join(tsBottom);

// Create the "Right" ToolStrip control and add
// to the corresponding ToolStripPanel.
ToolStrip tsRight = new ToolStrip();
tsRight.Items.Add("Right");
tspRight.Join(tsRight);

// Create the "Left" ToolStrip control and add
// to the corresponding ToolStripPanel.
ToolStrip tsLeft = new ToolStrip();
tsLeft.Items.Add("Left");
tspLeft.Join(tsLeft);

التحويل البرمجي للتعليمات البرمجية

يتطلب هذا المثال:

  • مراجع عن تجميعات النظام و تجميعات System.Design, System.Drawing, و System.Windows.Forms.

للحصول على المزيد من المعلومات حول إنشاء هذا المثال من خط أوامر Visual Basic أو #Visual C، راجع الإنشاء من سطر الأوامر (Visual Basic) أو إنشاء سطر الأوامر باستخدام csc.exe. يمكنك أيضاً بناء هذا المثال في Visual Studio عن طريق لصق التعليمات البرمجية في مشروع جديد. لمزيد من المعلومات، راجع: كيفية القيام بما يلي: ترجمة و تشغيل مثال التعليمات برمجية لنماذج Windows الكامل باستخدام ‏‫Visual Studio.

راجع أيضًا:

المهام

كيفية القيام بما يلي: استخدم ToolStripPanels ل MDI

المرجع

ToolStrip

ToolStripPanel