背景图应该随窗口的大小改变才对,当然窗口是随屏幕大小改变
重写窗口的paint方法
重写窗口的paint方法
解决方案 »
- c# 界面
- 如何赋空值的问题
- c#windows 连接到sql server 2008 的方法
- 怎样读取数据库里面的图片
- VS 2003中的ComboBox中添加自动完成功能,类似于VS 2005中的Sujest效果,有几个问题
- 如何用C#实现windows form的collapsing/expanding menu(类似qq,windows优化大师左面的系统菜单)?
- .NET里面的语言中(ASP,C#,C++...)哪种语言好点.学什么好点?
- 切换Form 10几次后出现stackoverflowerror异常~~急求解决办法
- 小弟在菜单里加入图标时发现:如果加入32*32的图标会显示的不完整!!(详情请进)
- datagridboolcolumn的三态问题?
- 新手上路,向大家请教个问题
- .net库中有没有类似于C++中的map类一样的类?
有好的方法再告之;
这才是c#的代码:
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.Controls.Add(this.pictureBox1);
把pictirebox置与最底层不行吗?不太懂你的意思;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication42
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button button1;
Bitmap myBitmap = new Bitmap(@"E:\MyPics\xia\图片 002.jpg");
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(48, 24);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.IsMdiContainer = true;
this.Name = "Form1";
this.Text = "Form1";
this.Resize += new System.EventHandler(this.Form1_Resize);
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Resize(object sender,EventArgs e)
{
Bitmap backImage=new Bitmap(myBitmap,this.Width ,this.Height );
this.BackgroundImage =backImage;
} private void Form1_Load(object sender, System.EventArgs e)
{
//看看这里;
Bitmap backImage=new Bitmap(myBitmap,this.Width ,this.Height );
this.BackgroundImage =backImage;
} private void button1_Click(object sender, System.EventArgs e)
{
Form2 form2=new Form2 ();
form2.MdiParent =this;
form2.Show ();
}
}
}
一个解决方法:
在主窗体里加入一个无边框的子窗体,在这个子窗体上加一个pictureBox:dock fill这个子窗体里
public class Test : System.Windows.Forms.Form
{
public Test()
{
InitializeComponent();
this.FormBorderStyle=FormBorderStyle.None;
this.Dock=DockStyle.Fill
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Test_Paint);
}private void Test_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
this.SendToBack();
}
这样不但可以用pictrueobx显示图片,还可以加其他的东东,比如说桌面图标