C#Winform技术,利用DataGridViewRow向DataGridView中添加数据

DataGridViewRow r1 = new DataGridViewRow(); r1.CreateCells(this.dataGridView1); r1.Cells[0].Value = false; r1.Cells[1].Value = type; r1.Cells[2].Value = …… 阅读全文

C#Winform判断DataGridView中的checkbox列是否选中

for (int i = 0; i < this.dataGridView1.Rows.Count; i++) { DataGridViewCheckBoxCell cb = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0]; bool …… 阅读全文

C#Winform实现高效率导入和导出Excel文件

/// /// 导出Excel文件 /// /// /// /// 数据集 /// 导出后是否打开文件 /// public static bool DataTableToExcel(string filePath, System.Data.DataTable dataTable …… 阅读全文

C#Winform通过连接访问Excel文件

OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "xls|*.xls"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { filePath = ofd …… 阅读全文

C#winform直接连接SQL数据库mdf文件

1.首先mdf文件必须是SQLServer2008及以下数据库,最好是2005版本的数据库2.将mdf文件这里以数据库文件“Test.mdf”为例,放于与程序Bin文件夹同文件夹下3.在Program.cs文件中,Main()方法下,添加如下代码string dataDir = AppDomain.CurrentDomain.BaseDirectory; if …… 阅读全文

C#中DataGridView控件绑定控件绑定数据源方式

第一种:DataSet ds=new DataSet (); this.dataGridView1.DataSource=ds.Table[0]; 第二种:DataTable dt=new DataTable(); this.dataGridView1.DataSource=dt; 第三种:DataSet ds=new DataSet (); this.dataGri …… 阅读全文