电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

基于C_的WinForm中DataGridView控件操作汇总

基于C_的WinForm中DataGridView控件操作汇总_第1页
1/23
基于C_的WinForm中DataGridView控件操作汇总_第2页
2/23
基于C_的WinForm中DataGridView控件操作汇总_第3页
3/23
下载后可任意编辑基于 C#的 WinForm 中 DataGridView 控件操作汇总一、单元格内容的操作 *****// 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index Console.WriteLine(DataGridView1.CurrentCell.ColumnIndex); // 取得当前单元格的行 Index Console.WriteLine(DataGridView1.CurrentCell.RowIndex);*******另外,使用 DataGridView.CurrentCellAddress 属性(而不是直接访问单元格)来确定单元格所在的行:DataGridView.CurrentCellAddress.Y 和列: DataGridView.CurrentCellAddress.X 。这对于避开取消共享行的共享非常有用。 当前的单元格可以通过设定 DataGridView 对象的 CurrentCell 来改变。可以通过 CurrentCell 来设定 DataGridView 的激活单元格。将 CurrentCell 设为 Nothing(null) 可以取消激活的单元格。// 设定 (0, 0) 为当前单元格 DataGridView1.CurrentCell = DataGridView1[0, 0]; 在整行选中模式开启时,你也可以通过 CurrentCell 来设定选定行。 /// /// 向下遍历 /// /// /// private void button4_Click(object sender, EventArgs e) ...{ int row = this.dataGridView1.CurrentRow.Index + 1; if (row > this.dataGridView1.RowCount - 1) row = 0; this.dataGridView1.CurrentCell = this.dataGridView1[0, row]; } /// /// 向上遍历 /// /// /// 下载后可任意编辑 private void button5_Click(object sender, EventArgs e) ...{ int row = this.dataGridView1.CurrentRow.Index - 1; if (row < 0) row = this.dataGridView1.RowCount - 1; this.dataGridView1.CurrentCell = this.dataGridView1[0, row]; } * 注意: this.dataGridView 的索引器的参数是: columnIndex, rowIndex 或是 columnName, rowIndex 这与习惯不同。********DataGridView 设定单元格只读:1) 使用 ReadOnly 属性 ? 假如希望,DataGridView 内所有单元格都不可编辑, 那么只要: // 设置 DataGridView1 为只读 DataGridView1.ReadOnly = true;此时,用户的新增行操作和删除行操作也被屏蔽了。 ******假如希望,Da...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

基于C_的WinForm中DataGridView控件操作汇总

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部