مشاركة عبر


كيفية القيام بما يلي: تحديد التي اللوحة في شريط المعلومات لنماذج Windows عنصر تحكم تم النقر

هام

تقوم عناصر تحكم StatusStrip و ToolStripStatusLabel باستبدال وإضافة الوظائف لعناصر تحكم StatusBar و StatusBarPanel; ومع ذلك، فإنه يتم الإحتفاظ بكلا عناصر تحكم StatusBar و StatusBarPanel الخاصة للإستخادم المستقبلي أو للتوافق مع الإصدارات السابقة, إذا اخترت القيام بذلك.

إلى برنامج the عنصر تحكم شريط المعلومات (Windows Forms) عنصر تحكم إلى respond إلى مستخدم clicks, استخدم a حالة كشف within the PanelClick حدث. The حدث يحتوي على an وسيطة (the لوحة وسيطة), which يحتوي على a مرجع إلى the clicked StatusBarPanel. Using this مرجع, you can determine the فهرس of the clicked لوحة, و برنامج accordingly.

ملاحظة

Ensure that the StatusBar عنصر تحكم's ShowPanels خاصية هو التعيين إلى true.

إلى determine which لوحة was clicked

  • في the PanelClick معالج الأحداث, استخدم a Select Case (في Visual Basic) أو switch case (#Visual C أو Visual C++) كشف إلى determine which لوحة was clicked بواسطة examining the فهرس of the clicked لوحة في the حدث الوسيطات.

    The following تعليمات برمجية مثال يتطلب the presence, تشغيل the نموذج, of a StatusBar عنصر تحكم, StatusBar1, و الثاني StatusBarPanel الكائنات, StatusBarPanel1 و StatusBarPanel2.

    Private Sub StatusBar1_PanelClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.StatusBarPanelClickEventArgs) Handles StatusBar1.PanelClick
       Select Case StatusBar1.Panels.IndexOf(e.StatusBarPanel)
         Case 0
           MessageBox.Show("You have clicked Panel One.")
         Case 1
           MessageBox.Show("You have clicked Panel Two.")
       End Select
    End Sub
    
    private void statusBar1_PanelClick(object sender, 
    System.Windows.Forms.StatusBarPanelClickEventArgs e)
    {
       switch (statusBar1.Panels.IndexOf(e.StatusBarPanel))
       {
          case 0 :
             MessageBox.Show("You have clicked Panel One.");
             break;
          case 1 :
             MessageBox.Show("You have clicked Panel Two.");
             break;
       }
    }
    
    private:
       void statusBar1_PanelClick(System::Object ^  sender,
          System::Windows::Forms::StatusBarPanelClickEventArgs ^  e)
       {
          switch (statusBar1->Panels->IndexOf(e->StatusBarPanel))
          {
             case 0 :
                MessageBox::Show("You have clicked Panel One.");
                break;
             case 1 :
                MessageBox::Show("You have clicked Panel Two.");
                break;
          }
       }
    

    (#Visual C, Visual C++) ضع التعليمات البرمجية التالية في منشئ النموذج لتسجيل معالج الأحداث.

    this.statusBar1.PanelClick += new 
       System.Windows.Forms.StatusBarPanelClickEventHandler 
       (this.statusBar1_PanelClick);
    
    this->statusBar1->PanelClick += gcnew
       System::Windows::Forms::StatusBarPanelClickEventHandler
       (this, &Form1::statusBar1_PanelClick);
    

راجع أيضًا:

المهام

كيفية القيام بما يلي: تعيين حجم فريق شريط المعلومات

الإرشادات التفصيلية: قم بتحديث المعلومات في شريط المعلومات عند وقت التشغيل

المرجع

نظرة عامة حول عرض شريط معلومات عنصر التحكم (Windows Forms)

StatusBar

ToolStripStatusLabel