DataGridView的一般用法(1)
来源:互联网 发布:淘宝搜索什么能看片 编辑:程序博客网 时间:2024/04/20 22:45
使用 DataGridView 控件,可以显示和编辑来自多种不同类型的数据源的表格数据。它的一般用法如下:
一.取得当前单元格的属性
1. 取得当前选中单元格的值
DataGridView1.CurrentCell.Value
2. 当前所在单元格所在列
DataGridView1.CurrentCell.ColumnIndex
3. 当前所在单元格所在行
DataGridView1.CurrentCell.RowIndel
4. 将控件中(0,0)处的值赋给当前单元格
DataGridView1.CurrentCell=DataGridView1(0,0)
二.DataGridView编辑属性
1.第二行设置为只读属性
DataGridView1.Rows.RemoveAt(0)
DataGridView1.Rows(2).ReadOnly=True
三.DataGridView行列不表示或者删除
1.行表头不表示
DataGridView1.RowHeadersVisible=False
2.指定行删除
DataGridView1.Rows.RemoveAt(0)
四.行列宽度高度设置为不能编辑
DataGridView1.AllowUserToResizeColumns=False
DataGridView1.AllowUserToResizeRows = False
2. 指定行列宽度高度不能编辑
DataGridView1.Columns(0).Resizable=DataGridViewTriState.False
DataGridView1.Rows(0).Resizable = DataGridViewTriState.False
五.DataGridView选择的行、列、单元格取得
For Each c As DataGridViewCell In DataGridView1.SelectedCells Console.WriteLine("{0}, {1}", c.ColumnIndex, c.RowIndex) Next cFor Each r As DataGridViewRow In DataGridView1.SelectedRows Console.WriteLine(r.Index) Next rFor Each c As DataGridViewColumn In DataGridView1.SelectedColumns Console.WriteLine(c.Index) Next c
六.取得指定单元格
DataGridView1(0, 0).Selected = TrueDataGridView1.Rows(1).Selected = TrueDataGridView1.Columns(2).Selected = True
- DataGridView的一般用法(1)
- DataGridView 数据绑定的一般过程
- DataGridView一般获取与设定的操作
- DataGridView的常用用法
- Iterator(迭代器)的一般用法
- Iterator(迭代器)的一般用法 (转)
- Java中迭代器(Iterator)的一般用法
- #pragma的一般用法
- enum的一般用法
- Iterator 的一般用法
- shape 的一般用法
- vector的一般用法
- Queue的一般用法
- NSNumberFormatter的一般用法
- ierator的一般用法
- 注释的一般用法
- scanf的一般用法
- 迭代器的一般用法
- html 强制换行
- Measure data roaming traffic on Android?
- 利用SPring AOP配置切面的一个例子
- Android笔记(3)——系统时间的获取与音量控制
- hdu 3666 THE MATRIX PROBLEM //2010哈尔滨现场赛
- DataGridView的一般用法(1)
- Windows 电脑命令一览
- MSSQL设计主键类型
- Using the Android Application class to persist data
- 在Oracle中使用rank()over()排名的问题 .
- 嵌入式笔试题荟萃
- Build the Android work environment in Ubuntu Linux
- vs2005取消代码编辑区自动换行
- Android 中自定义View的应用