مشاركة عبر


كيفية القيام بما يلي: تمكين الجدولة بين الأشكال (‏‫Visual Studio)

عناصر تحكم الخط و الشكل لا تحتوي خصائص TabStop أو TabIndex ، و لكن ما زال بإمكانك الجدولة بينها. و في المثال التالي ، الضغط على زر'Ctrl' و مفاتيح TAB للتبويب بين الأشكال ; في حين الضغط على مفتاح TAB يقوم بالتبويب بين الأزرار.

ملاحظة

قد يعرض جهاز الكمبيوتر الخاص بك أسماء أو مواقع مختلفة لبعض عناصر واجهة مستخدم Visual Studio في الإرشادات التالية. يحدد كل من إصدار Visual Studio لديك والإعدادات المستخدمة هذه العناصر. لمزيد من المعلومات، راجع العمل مع إعدادات.

للإتاحة الجدولة بين الأشكال

  1. اسحب ثلاث عناصر تحكم RectangleShape و عنصري تحكم Button من مربع الأدوات للنموذج.

  2. في محرر التعليمات البرمجية, قم بإضافة كشف Imports أو using في الجزء العلوي من الوحدة النمطية:

    Imports Microsoft.VisualBasic.PowerPacks
    
    using Microsoft.VisualBasic.PowerPacks;
    
  3. قم بإضافة التعليمات البرمجية التالية في إجراء الحدث :

    Private Sub Shapes_PreviewKeyDown(
        ByVal sender As Object, 
        ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs
      ) Handles RectangleShape1.PreviewKeyDown, 
                RectangleShape2.PreviewKeyDown, 
                RectangleShape3.PreviewKeyDown
    
        Dim sh As Shape
        ' Check for the Control and Tab keys.
        If e.KeyCode = Keys.Tab And e.Modifiers = Keys.Control Then
            ' Find the next shape in the order.
            sh = ShapeContainer1.GetNextShape(sender, True)
            ' Select the next shape.
            ShapeContainer1.SelectNextShape(sender, False, True)
        End If
    End Sub
    
    private void shapes_PreviewKeyDown(Shape sender, System.Windows.Forms.PreviewKeyDownEventArgs e)
    {
        Shape sh;
        // Check for the Control and Tab keys.
        if (e.KeyCode == Keys.Tab && e.Modifiers == Keys.Control)
        // Find the next shape in the order.
        {
            sh = shapeContainer1.GetNextShape(sender, true);
            // Select the next shape.
            shapeContainer1.SelectNextShape(sender, false, true);
        }
    }
    
  4. قم بإضافة تعليمات برمجية التالية في إجراء حدث Button1_PreviewKeyDown :

    Private Sub Button1_PreviewKeyDown(
        ByVal sender As Object, 
        ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs
      ) Handles Button1.PreviewKeyDown
    
        ' Check for the Control and Tab keys.
        If e.KeyCode = Keys.Tab And e.Modifiers = Keys.Control Then
            ' Select the first shape.
            RectangleShape1.Select()
        End If
    End Sub
    
    private void button1_PreviewKeyDown(object sender, System.Windows.Forms.PreviewKeyDownEventArgs e)
    {
        // Check for the Control and Tab keys.
        if (e.KeyCode == Keys.Tab & e.Modifiers == Keys.Control)
        // Select the first shape.
        {
            rectangleShape1.Select();
        }
    }
    

راجع أيضًا:

المهام

كيفية القيام بما يلي: رسم أشكال مع عناصر التحكم OvalShape و RectangleShape (‏‫Visual Studio)

كيفية القيام بما يلي: رسم خطوط ذات عنصر التحكم LineShape (‏‫Visual Studio)

المبادئ

مقدمة إلى عناصر التحكم الشكل و الخط (‏‫Visual Studio)