110,534
社区成员
发帖
与我相关
我的任务
分享
private void FormBase_Load(object sender, EventArgs e)
{
PictureBox pb = new PictureBox();
Bitmap image = new Bitmap("Autumn.jpg");
pb.BackgroundImage = image;
pb.BackgroundImageLayout = ImageLayout.Stretch;
pb.Location = new Point(0, 0);
pb.Width = 300;
pb.Height = 200;
this.Controls.Add(pb);
this.BackColor = Color.Black;
foreach (Control control in this.Controls)
{
if (control.ForeColor == SystemColors.ControlDarkDark ||
control.ForeColor == SystemColors.ControlText)
{
control.ForeColor = Color.White;
}
}
}
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "BaseForm";
}
#endregion
//在OnPain时间中添加
base.OnPain(e);
e.Griphics.DrawImage(Image.FromFile("filePath"),this.Bound); //绘制背景图
//可能拼写有点错误