vs2008和c#中怎样利用Bitmap (String, Boolean)函数给winform加载图片图片
时间:2011-12-15
来源:互联网
我用vs2008和c#来开发一个小系统。现在利用Bitmap 构造函数 (String, Boolean)来给winform加载背景,想通过小系统自己设计来换背景(不想利用from属性来添加背景图片), 我就利用这句话来编写的程序
this.BackgroundImage = new Bitmap(this.MyBgPhotoShow, true);
一编译就出错。
提示如下:未处理 System.ArgumentException
Message="参数无效。"
Source="System.Drawing"
StackTrace:
在 System.Drawing.Bitmap..ctor(String filename, Boolean useIcm)
在 高新置业.MainForm.MainForm_Load_1(Object sender, EventArgs e) 位置 C:\Users\LIHONGBO\Desktop\毕业设计--项目\高新置业房产中介管理系统\高新置业房产中介管理系统\高新置业\MainForm.cs:行号 49
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 高新置业.MainForm.WndProc(Message& SystemMessage) 位置 C:\Users\LIHONGBO\Desktop\毕业设计--项目\高新置业房产中介管理系统\高新置业房产中介管理系统\高新置业\MainForm.cs:行号 75
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 高新置业.Program.Main() 位置 C:\Users\LIHONGBO\Desktop\毕业设计--项目\高新置业房产中介管理系统\高新置业房产中介管理系统\高新置业\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
在 System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
在 System.Activator.CreateInstance(ActivationContext activationContext)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
this.BackgroundImage = new Bitmap(this.MyBgPhotoShow, true);
一编译就出错。
提示如下:未处理 System.ArgumentException
Message="参数无效。"
Source="System.Drawing"
StackTrace:
在 System.Drawing.Bitmap..ctor(String filename, Boolean useIcm)
在 高新置业.MainForm.MainForm_Load_1(Object sender, EventArgs e) 位置 C:\Users\LIHONGBO\Desktop\毕业设计--项目\高新置业房产中介管理系统\高新置业房产中介管理系统\高新置业\MainForm.cs:行号 49
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 高新置业.MainForm.WndProc(Message& SystemMessage) 位置 C:\Users\LIHONGBO\Desktop\毕业设计--项目\高新置业房产中介管理系统\高新置业房产中介管理系统\高新置业\MainForm.cs:行号 75
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 高新置业.Program.Main() 位置 C:\Users\LIHONGBO\Desktop\毕业设计--项目\高新置业房产中介管理系统\高新置业房产中介管理系统\高新置业\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
在 System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
在 System.Activator.CreateInstance(ActivationContext activationContext)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
作者: guokao666 发布时间: 2011-12-15
C# code
Bitmap pic = new Bitmap(@path);//path为图路径 this.BackgroundImage = pic;
作者: DENQH 发布时间: 2011-12-15
this.BackgroundImage = Bitmap.FromFile("图片路径");
作者: mayswind 发布时间: 2011-12-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28