随笔分类 - C#
C#
摘要:C# DataGridView控件 动态添加新行DataGridView控件在实际应用中非常实用,特别需要表格显示数据时。可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行。假如需要动态为DataGridView控件添加新行,方法有很多种,下面简单介绍如何为DataGridView控件动态添加新行的两种方法:方法一:int index=this.dataGridView1.Rows.Add();this.dataGridView1.Rows[index].Cells[0].Value = "1"; this.dataGridView1.Rows[ind
阅读全文
摘要:判断dataset为空以及dataset中是否有表以及表中是否有数据一般都知道使用dataset时先判断它是否为空,但我开始对ds为空的概念有点模糊,在网上查了下,结果如下:DataSet为空和DataSet中没有表是两回事。 DataSet为空,或者说DataSet类型的引用为空是指这个引用型变量未指向任何new出来的内存块。 ds:DataSetif(ds == null) //ds为空if(ds.Tables.Count == 0) //ds中没有表if(ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0) //ds中
阅读全文
摘要:控制textbox里边只输入数字 void textboxnum(KeyPressEventArgs e) { if ((e.KeyChar > (char)47 && e.KeyChar < (char)58) || e.KeyChar == (char)8) { e.Handled = false; } else { e.Handled = true; } } priv...
阅读全文
摘要:第一种方案:1.可以写一个函数MdiChildShow(Form frm)2.如果你要打开的窗体是Form1.Form1 frm = new Form1(frm);this.MdiChildShow(frm);函数代码如下://Mdi子窗口不能重复打开 private void MdiChildShow(Form f) { bool isOpen = true; foreach (Form frm in this.MdiChildren) //遍历已打开的MDI { if (frm.Name == f.Name) { frm.Activate(); //赋予焦点,到最前面来 f...
阅读全文
浙公网安备 33010602011771号