摘要: 如何将可空int转换为int ? 假设我有两种类型的int,如下所示: int? v1; int v2; //将v1的值分配给v2 。 v2 = v1; 会导致错误。 如何将v1转换为v2? v2 = Convert.ToInt32(v1); v2=(int)v1; //检索对象的值。 如果为nul 阅读全文
posted @ 2020-12-14 14:26 ₯㎕~ 阅读(164) 评论(0) 推荐(0) 编辑
摘要: //dgvVisitor 是DataGridView的名称 dgvVisitor.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //单元格居中显示 private void dgvVisitor 阅读全文
posted @ 2020-12-01 12:21 ₯㎕~ 阅读(1990) 评论(0) 推荐(0) 编辑
摘要: #region 在图片框中显示相应大小的图片 private Bitmap ResizeImage(Bitmap bmp, PictureBox picBox) { float xRate = (float)bmp.Width / picBox.Size.Width;//比较picBox的宽度与图片 阅读全文
posted @ 2020-11-30 17:29 ₯㎕~ 阅读(456) 评论(0) 推荐(0) 编辑
摘要: 【第一种方法:】 第一步: 创建接口IForm,父窗体继承这个接口 public interface IForm { void RefreshForm(); } 第二步: 父窗体实现接口中的方法,在实现接口的方法中写入刷新代码 Form2 f = new Form2(); f.Owner = thi 阅读全文
posted @ 2020-11-23 15:47 ₯㎕~ 阅读(491) 评论(0) 推荐(0) 编辑
摘要: DataTable dt = ds.Tables[0]; DataRow[] drs = dt.Select("Id=" + categoryID ); 解决方法:将参数用单引号阔起来 DataRow[] drs = dt.Select("Id='" + categoryID + "'");C# D 阅读全文
posted @ 2020-11-20 16:56 ₯㎕~ 阅读(235) 评论(0) 推荐(0) 编辑
摘要: //错误代码 Bitmap 对象或一个 图像 对象从一个文件, 构造时该文件仍保留锁定对于对象的生存期。 因此, 无法更改图像并将其保存回它产生相同的文件。private static byte[] GetBytes (Image image) { try { if (image == null) 阅读全文
posted @ 2020-11-16 14:57 ₯㎕~ 阅读(586) 评论(0) 推荐(0) 编辑
摘要: private Point pi;//定义一个坐标变量 //TreeRule为TreeView的Name private void TreeRule_MouseDown(object sender, MouseEventArgs e)//当鼠标指针位于控件上并按下鼠标键时发生 { pi = new 阅读全文
posted @ 2020-11-03 15:43 ₯㎕~ 阅读(746) 评论(0) 推荐(0) 编辑
摘要: //创建字典Dictionary 对象 Dictionary<string, int> dic = new Dictionary<string, int>(); //.net 3.5 以上版本 Dictionary排序(即 linq dictionary 排序) private void Dicto 阅读全文
posted @ 2020-09-28 11:05 ₯㎕~ 阅读(338) 评论(0) 推荐(0) 编辑
摘要: private string ReplaceChange(string str) { if (!string.IsNullOrEmpty(str)) { //将特殊字符全部替换为下划线 string pattern = "[\\[ \\] \\^ \\-_*×――(^)$%~!@#$…&%¥—+=< 阅读全文
posted @ 2020-09-16 16:09 ₯㎕~ 阅读(504) 评论(0) 推荐(0) 编辑
摘要: //DataGridView扩展类//WDataGridView控件 public class WDataGridViewColumn_EditDelete : DataGridViewColumn { /// <summary> /// 对象名称:DataGridView操作按钮列(修改、删除) 阅读全文
posted @ 2020-07-15 14:53 ₯㎕~ 阅读(1421) 评论(0) 推荐(0) 编辑