C# dataGridView的使用
来源:互联网 发布:服务器远程桌面端口 编辑:程序博客网 时间:2024/06/06 13:56
1、往dataGridView中添加多行数据:
for (int i = 0; i < listCar.Count; i++) { Car car = listCar[i]; int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = car.Type; this.dataGridView1.Rows[index].Cells[1].Value = car.CarType; this.dataGridView1.Rows[index].Cells[2].Value = car.PlateNum; this.dataGridView1.Rows[index].Cells[3].Value = car.Price; this.dataGridView1.Rows[index].Cells[4].Value = car.IsDelete; }2、清空DataGridView中的所有行:
this.dataGridView1.Rows.Clear();
3、删除DataGridView中指定行:
this.dataGridView1.Rows.RemoveAt(1);
4、删除最后一行空白行:
将属性中AllowUserToAddRows置为为false。
5、往DataGridView添加一列按钮:
DataGridViewButtonColumn button = new DataGridViewButtonColumn(); button.HeaderText = "操作";//列标题名 button.Text = "删除";//按钮显示名字 button.UseColumnTextForButtonValue = true; this.dataGridView1.Columns.AddRange(button);效果:
5.1、对所添加的按钮进行事件监听:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int CIndex = e.RowIndex;//获取所点击的行数 MessageBox.Show(CIndex+"");//使用提示框显示当前行数 }
效果:
0 0
- C# dataGridView的使用
- C#中DataGridView的使用
- C# Datagridview控件的使用
- c# DataGridView控件的使用
- c#2.0 中的 dataGridView 的使用
- C#中使用DataGridView的一些问题
- c# DataGridView控件的使用补充--属性
- C#中DataGridView使用
- C# DataGridView 使用
- c# DataGridView控件使用
- c# datagridview 使用大全
- C# DataGridView 使用
- c# datagridview 使用大全
- C# datagridview使用
- C#中DataGridView使用
- c# dataGridView的应用
- C# WinForm DataGridView控件使用
- DataGridView/C#使用SqlDataAdapte…
- c++学习笔记十五
- Unity Profiler工具的使用
- java招聘要求总结
- Java动态代理简单应用
- c++学习笔记十六
- C# dataGridView的使用
- QRegExp 设置正则表达式
- MBProgressHUD提示框(进度条)
- 一个非常好用的工具,可以多人同时创作
- c++学习笔记十七
- android-打包安装过程
- [android] No resource found that matches the given name 'Theme.AppCompat.Light'
- PHP程序员应该知道的15个库
- C实现的简单键值对