كيفية القيام بما يلي: تعيين خلفية لوحة Windows Forms

يمكن لعنصر تحكم Windows FormsPanel عرض كلا من لون الخلفية و صورة الخلفية. تعين خاصية BackColor لون الخلفية لعناصر التحكم المضمنة، مثل أزرار الخيارات والتسميات. إذا كانت الخاصية BackgroundImage ليست معينة، مقطع BackColor سيملأ اللوحة بأكملها. إذا كانت الخاصية BackgroundImage تم تعيينها، سيتم عرض الصورة خلف عناصر التحكم المضمنة.

لتعيين الخلفية برمجياً

  1. قم بتعيين خاصية اللوحة BackColor لقيمة من النوع System.Drawing.Color.

    Panel1.BackColor = Color.AliceBlue
    
    panel1.BackColor = Color.AliceBlue;
    
    panel1->BackColor = Color::AliceBlue;
    
  2. قم بتعيين خاصية اللوحة BackgroundImage باستخدام أسلوب FromFile الخاص بالفئة System.Drawing.Image.

    ' You should replace the bolded image 
    ' in the sample below with an image of your own choosing.
    Panel1.BackgroundImage = Image.FromFile _
        (System.Environment.GetFolderPath _
        (System.Environment.SpecialFolder.Personal) _
        & "\Image.gif")
    
    // You should replace the bolded image 
    // in the sample below with an image of your own choosing.
    // Note the escape character used (@) when specifying the path.
    panel1.BackgroundImage = Image.FromFile
       (System.Environment.GetFolderPath
       (System.Environment.SpecialFolder.Personal)
       + @"\Image.gif");
    
    // You should replace the bolded image 
    // in the sample below with an image of your own choosing.
    panel1->BackgroundImage = Image::FromFile(String::Concat(
       System::Environment::GetFolderPath
       (System::Environment::SpecialFolder::Personal),
       "\\Image.gif"));
    

راجع أيضًا:

المرجع

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

BackColor

BackgroundImage

موارد أخرى

لوحة عنصر تحكم (Windows Forms)