Windows フォーム Panel コントロールでは、背景色と背景画像の両方を表示できます。 BackColor プロパティは、ラベルやラジオ ボタンなど、含まれているコントロールの背景色を設定します。 BackgroundImage プロパティが設定されていない場合は、BackColor 選択がパネル全体に表示されます。 BackgroundImage プロパティが設定されている場合、イメージは含まれているコントロールの背後に表示されます。
プログラムで背景を設定するには
パネルの BackColor プロパティを System.Drawing.Color型の値に設定します。
Panel1.BackColor = Color.AliceBlue
panel1.BackColor = Color.AliceBlue;
panel1->BackColor = Color::AliceBlue;
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"));
こちらも参照ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET Desktop feedback