未能加载文件或程序集”的解决方法
摘要:1.相同版本操作系统复制C:\Windows\assembly这个文件夹替换有问题的电脑同名文件
阅读全文
posted @
2014-03-14 09:34
清风暮雨
阅读(596)
推荐(0)
C# 使MessageBox.Show弹出框保持最前
摘要:MessageBox.Show("要弹的信息。", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information,MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
阅读全文
posted @
2014-03-13 17:17
清风暮雨
阅读(4818)
推荐(0)
C# 让DataGridView的时间列显示时分秒
摘要:this.dgvParent.Columns["创建日期"].DefaultCellStyle.Format = "yyyy-MM-dd hh:mm:ss";
阅读全文
posted @
2014-03-04 10:30
清风暮雨
阅读(1369)
推荐(0)
DataGridView 点击选择行时不进入编辑模式
摘要:方法一:使用变通的办法,让另一个控件获得焦点控件.Focus();
阅读全文
posted @
2014-02-27 19:30
清风暮雨
阅读(216)
推荐(0)
在Form_Load里面调用Focus无效的解决方法
摘要:在Form_Load里面添加了listview1.Focus();结果没效果。解决方法:在Focus()之前调用this.Show();或者更简单的,把Focus()函数调用移到Form_Shown事件处理中。
阅读全文
posted @
2014-02-26 19:46
清风暮雨
阅读(154)
推荐(0)
C# 把datagridview中的自动排序功能禁用
摘要:1 方法一:2 DataGridView中的Columns属性里面可以设置。进入“EditColumns”窗口后,在相应的列属性设置里面把SortMode属性选择为"NotSortable"3 4 方法二:5 for (int i = 0; i < this.dataGridView1.Columns.Count;i++) { 6 this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; 7 }
阅读全文
posted @
2014-02-24 15:40
清风暮雨
阅读(1692)
推荐(0)
C# 去掉DataGridView最左边的空白列
摘要:去掉DataGridView最左边的空白列DataGridView.RowHeadersVisible=false; //知识拓展DataGridView.SelectionMode=DataGridViewSelectionMode.FullRowSelect;注:如果DataGridView.EditMode==DataGridViewEditMode.EditOnEnter的话,那么单击单元格,会进入编辑状态,而非选中一整行。
阅读全文
posted @
2014-02-21 14:02
清风暮雨
阅读(7073)
推荐(1)
C#子窗体关闭后刷新父窗体和修改子窗体马上刷新父窗体数据
摘要:一.子窗体关闭后刷新父窗体1.父窗体代码 1 private void button1_Click(object sender, EventArgs e) 2 { 3 Form2 f = new Form2(); 4 f.OnSave += new Form2.Save...
阅读全文
posted @
2014-02-20 12:36
清风暮雨
阅读(1837)
推荐(0)
SQL server 中 power()命令的作用
摘要:power(X,Y)函数是计算X的Y次幂的!例如:power(2,5)= 32
阅读全文
posted @
2014-01-22 10:19
清风暮雨
阅读(669)
推荐(0)
C# 为控件注册快捷键
摘要:1 #region 注册快捷键 2 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 3 { 4 switch (keyData) 5 { 6 case Keys.Control | Keys.A: 7 this.AddNew(); 8 break; 9 case Keys.Contr...
阅读全文
posted @
2014-01-20 14:05
清风暮雨
阅读(132)
推荐(0)
C# DataGridVewX控件报无厘头错误时
摘要:DataGridVewX控件报无厘头错误时,可添加以下代码:1.添加事件:1 //添加该事件是为了防止弹出默认错误异常提示框2 private void dgDetails_summary_DataError(object sender, DataGridViewDataErrorEventArgs e)3 {4 5 }2.添加代码:1 this.dgDetails_summary.CurrentCell = this.dgDetails_summary.Rows[0].Cells["编码"]; //此行代码务必加上,不加则会发生错误
阅读全文
posted @
2013-12-20 12:02
清风暮雨
阅读(148)
推荐(0)
C# WinForm清空界面控件值的小技巧
摘要:1 一般的做法是在清除控件的事件里面添加下面这样的代码: 2 3 private void btnClear_Click(objectsender, EventArgs e) 4 { 5 this.txbAccount.Text = ""; 6 this.txbAddress.Text = ""; 7 this.txbCmp.Text = ""; 8 this.chkCash.Checked = false; 9 this.cmbDepart.Text = "...
阅读全文
posted @
2013-12-19 09:46
清风暮雨
阅读(823)
推荐(0)
C# DOCK属性在代码中赋值Fill
摘要:控件名.Dock = DockStyle.Fill;
阅读全文
posted @
2013-12-19 09:30
清风暮雨
阅读(1374)
推荐(0)
C# 获取DataGridView控件选中行的集合
摘要:1 //先判断是否有勾选行,有勾选则只导出勾选的行。 2 //定义和DataGridView控件内容结构相同的DataTable 3 //dtCartClo是DataGridView的数据源 4 DataTable dtDgv = this.dtCartClo.Clone();// 5 foreach (DataGridViewRow dgRow in this.dgvxCtnPOC.Rows) 6 { 7 ...
阅读全文
posted @
2013-12-04 11:42
清风暮雨
阅读(1346)
推荐(0)
C# 关于DataGridView控件带选择框,要求选择框可以勾选,但是行不能处于编辑状态。
摘要:解决办法一:1.设置DataGridView控件的ReadOnly属性为true。目的是设置DataGridView控件不可编辑。2.在代码中实现 1 #region 单击选择 2 private void dgvxCtnPOC_CellClick(object sender, DataGridViewCellEventArgs e) 3 { 4 if (e.RowIndex == -1) 5 return; 6 else 7 { 8 ...
阅读全文
posted @
2013-12-04 11:36
清风暮雨
阅读(3294)
推荐(0)
C# 该行已经属于另一个表
摘要://将数组元素加入表...dt.Rows.Add(dr[i]);//出错提示为:该行已经属于另一个表解决方法dt.Rows.Add(dr[i].ItemArray);
阅读全文
posted @
2013-12-04 10:06
清风暮雨
阅读(124)
推荐(0)
C# 取DataTable某一列,并去掉该列的重复值。
摘要:1 DataTable dtDgv = this.dgvxCtnPOC.DataSource as DataTable; 2 DataView dView = dtDgv.DefaultView; 3 //取DataTable的某一列,并去掉重复。true表示去重,false保留重复。 4 dtDgv = dView.ToTable(true,"ContainerNum"); 5 foreach (DataRow dr in dtDgv.Rows) 6 { 7 //判断是否有空行 方法一 8 if (dr["ContainerNum"].Equals(D
阅读全文
posted @
2013-12-03 11:29
清风暮雨
阅读(3070)
推荐(0)
给DataGridView控件画行号
摘要:1 private void dgvxCartCode_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) 2 { 3 this.PointRowNumber((DataGridView)sender, e); 4 } 5 6 /// 7 /// 给DataGridView控件画行号 8 /// 9 /// 10 /// 11 public void PointRowNumb...
阅读全文
posted @
2013-11-29 10:33
清风暮雨
阅读(145)
推荐(0)
c# 窗体固定大小
摘要:窗口属性:maxsize和minsize,把这两个设置成一样的数值。
阅读全文
posted @
2013-11-06 15:39
清风暮雨
阅读(1649)
推荐(0)
DataGridView在多线程中无法显示滚动条
摘要:在多线程中对DataGridView指定 DataSource 来填充数据,更新数据的时候,会导致滚动条无法显示的问题,在保证了DataGridView的ScrollBars设置为了Both,数据量大于DataGridView显示的的范围的情况下,解决方法如下:一是使用 Invoke 将执行数据绑定...
阅读全文
posted @
2013-11-05 09:47
清风暮雨
阅读(347)
推荐(0)