随笔分类 - Winform
Winform
摘要:1.在一个项目中,一个Library 调用另外一个Library的可执行文件时,如果用Process.Start(exe文件)(如果该exe文件没有相关的配置文件,则可以执行成功),但是如果有相关的配置文件,则会出现该exe文件已停止工作的错误提示。出现这样的原因是这样的,本身调用的时候,目录是自己bin/debug文件夹的路径,之后你设置其他路径的时候,就会出现错误,可以用cmd调试测试下,直接打开cmd,将exe要调用的程序放入cmd中执行,看是否出错,如果不出错,那么使用Process.Start("exe文件")调用也没问题的,如果出错,则是路径的问题。解决方法:程
阅读全文
摘要:/// /// 压缩图片 /// /// 要压缩的图片的路径 /// 压缩后的图片的路径 public void ChangeImageSize(string filePath, string newfilePath) { Bitmap bmp = null; ImageCodecInfo ici = null; System.Drawing.Imaging.Encoder ecd = null; EncoderParameter ept = null; EncoderParameters eptS = null; try { bmp = new Bitmap(filePath); ic...
阅读全文
摘要:#region 原图大小Bitmap sourceBitmap = new Bitmap(picBox.Width, picBox.Height);panelImage.DrawToBitmap(sourceBitmap, new Rectangle(0, 0, picBox.Width, picBox.Height));#endregion#region 区域截取Image imageSource = sourceBitmap;或者(Image.FromFile(filepath))double orgWidth = IntDouble(imageSource.Width);double o
阅读全文
摘要:[DllImport("kernel32.dll")] public static extern IntPtr _lopen(string lpPathName, int iReadWrite); [DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr hObject); public const int OF_READWRITE = 2; public const int OF_SHARE_DENY_NONE = 0x40; public readonly Int
阅读全文
摘要:转:解决DataGridView在多线程中无法显示滚动条的问题 在多线程中对DataGridView指定 DataSource 来填充数据,更新数据的时候,会导致DataGridView出现假死,显示错误或者滚动条无法显示的问题,在保证了DataGridView的ScrollBars设置为了Both,数据量大于DataGridView显示的的范围,而且没有冻结列的情况下,解决方法如下:一是使用 Invoke 将执行数据绑定的代码交回给主线程(因为 DataGridView 是主线程创建的);二是在指定 DataSource 之前,将其置为 null。private delegate void
阅读全文

浙公网安备 33010602011771号