首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > C# > C# 显示DataGridView控件中选定的单元格、行和列

C# 显示DataGridView控件中选定的单元格、行和列

  • 资源大小:142.92 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: C#源码

资 源 简 介

Visual C#显示选择的DataGridView单元格,获取DataGridView控件中选定的单元格、行和列,测试前请连接好数据库,实现此功能核心代码如下:   if (customersDataGridView.AreAllCellsSelected(true))   {    MessageBox.Show("所有单元格已经被选择!", "信息提示",MessageBoxButtons.OK);   }   else   {    System.Text.StringBuilder MyInfo =new System.Text.StringBuilder();    for (int i = 0;    i < MyCount; i++)    {    MyInfo.Append("行号: ");    MyInfo.Append(customersDataGridView.SelectedCells[i].RowIndex.ToString());    MyInfo.Append(", 列号: ");    MyInfo.Append(customersDataGridView.SelectedCells[i].ColumnIndex.ToString());    MyInfo.Append(", 单元格值: ");    MyInfo.Append(customersDataGridView.SelectedCells[i].Value.ToString());    MyInfo.Append(Environment.NewLine);    }    MyInfo.Append("一共选择了: " + MyCount.ToString()+"个单元格");    MessageBox.Show(MyInfo.ToString(), "信息提示", MessageBoxButtons.OK);   }

文 件 列 表

srcfans.com
DataGridView
MyForm
bin
Release
MyForm.exe
DataGridView
DataGridView
MyForm
app.config
srcfans.com
VIP VIP
0.248573s