Sri*_*ati 11 c# icons picturebox
我想icon file在一个图片框中显示.我正在使用此代码来设置图像.
pictureBox1.Image = new Icon(openFileDialog.FileName, new Size(48, 48)).ToBitmap();
Run Code Online (Sandbox Code Playgroud)
但我得到了这个例外.
System.ArgumentOutOfRangeException: Requested range extends past the end of the array.
at System.Runtime.InteropServices.Marshal.CopyToNative(Object source, Int32 startIndex, IntPtr destination, Int32 length)
at System.Runtime.InteropServices.Marshal.Copy(Byte[] source, Int32 startIndex, IntPtr destination, Int32 length)
at System.Drawing.Icon.ToBitmap()
Run Code Online (Sandbox Code Playgroud)
如何克服这个问题?
谢谢.
解决了这个问题.
pictureBox1.Image = Bitmap.FromHicon(new Icon(openFileDialog.FileName, new Size(48, 48)).Handle);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13454 次 |
| 最近记录: |