菜鸟问题,C#中我怎样单击一个按钮,在窗体上显示一个BMP文件?? System.Drawing.Bitmap myBit=new System.Drawing.Bitmap( 图片文件名,false);this.BackgroundImage =myBit;this.Refresh(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to 愚翁:我就是用的System.Drawing我的代码如下 private void button1_Click(object sender, System.EventArgs e) { Image imgMyImg; imgMyImg=new Bitmap(@"f:\zhengjia.bmp"); Graphics GraphicsMyg; GraphicsMyg.DrawImage(imgMyImg,20,150); }运行时告诉我说:F:\C#\loadbmp\loadbmp\loadbmp\Form1.cs(115): Use of unassigned local variable 'GraphicsMyg' 把后两句改一下Graphics GraphicsMyg=this.CreateGraphics();GraphicsMyg.DrawImage(imgMyImg,20,150); 我也想到了!!我没有创建Graphics对象. 感谢愚翁!!! 视频转换 树形结构的问题 如何判断记录是否存在呢? 发布投票的一点小问题 询问一个学习C#最好的办法 输入一串字符,如"this is test",将这串字符反向输出,也就是"test is this",请问大哥大姐怎么去实现它,请贴出代码,谢谢. 一个按钮点击事件里调用了一个新线程,新线程调用了一个process,怎么判断这个进程执行完毕啊? 19寸屏幕设计窗体按钮规格有变化 MDI窗体中打开子窗体时 如何让子窗体的位置固定? 有没有设计类图的想法 petshop示例中xml存入存储过程为什么含有中文字符就会出错? 关闭当前窗口与关闭本系统分别用什么命令?
我就是用的System.Drawing
我的代码如下
private void button1_Click(object sender, System.EventArgs e)
{
Image imgMyImg;
imgMyImg=new Bitmap(@"f:\zhengjia.bmp");
Graphics GraphicsMyg;
GraphicsMyg.DrawImage(imgMyImg,20,150);
}运行时告诉我说:F:\C#\loadbmp\loadbmp\loadbmp\Form1.cs(115): Use of unassigned local variable 'GraphicsMyg'
Graphics GraphicsMyg=this.CreateGraphics();
GraphicsMyg.DrawImage(imgMyImg,20,150);
感谢愚翁!!!