登录
首页 » C#源码 » C# 显示选择的DataGridView单元格行数据

C# 显示选择的DataGridView单元格行数据

于 2022-12-31 发布 文件大小:97.84 kB
0 186
下载积分: 2 下载次数: 1

代码说明:

C# 显示选择的DataGridView单元格行数据附实现源码,连接数据库后,单击上部的“显示选择的单元格行”功能,即可显示出该行数据,具体的实现代码如下:   private void toolStripButton1_Click(object sender, EventArgs e)   {//显示选择的单元格行(获取DataGridView控件中选定的单元格行)   Int32 MyCount =customersDataGridView.Rows.GetRowCount(DataGridViewElementStates.Selected);   if (MyCount > 0)   {    System.Text.StringBuilder MyInfo = new System.Text.StringBuilder();    for (int i = 0; i < MyCount; i++)    {    MyInfo.Append("被选择的行号是: ");    MyInfo.Append(customersDataGridView.SelectedRows[i].Index.ToString());    MyInfo.Append(Environment.NewLine);    }    MyInfo.Append("一共选择了: " + MyCount.ToString()+"行。");    MessageBox.Show(MyInfo.ToString(), "信息提示",MessageBoxButtons.OK);   }   }

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • C#监测服务运行
    C#监测服务运行源码,监测服务的运行,且服务重启时会给相应用户发邮件
    2022-01-26 04:33:30下载
    积分:1
  • C# 2015 在按钮中调用出下拉菜单的
    C# 2015 在按钮中调用出下拉菜单的源码,在按钮中显示一个下拉菜单的小三角,用户单击这个小三角即可显示出下拉菜单,这种用法之前也有不少,但有些新手不知道如何实现,希望通过这个简单的例子源码,你会学习到一些相关的知识技巧,制作出按钮下拉菜单的风格来。
    2023-02-15 19:40:04下载
    积分:1
  • 恒拓开飞控
    纯C代码开发的开源飞控,不用操作系统,裸机程序稳定性更高
    2022-06-12 04:39:04下载
    积分:1
  • STM32F1的SPWM逆变器
    #include "SPWM.h" #include "led.h" #include "usart.h" u16 TimerPeriod = 7200; u16 DutyFactor = 50; void TIM_Int_Init(void) {  GPIO_InitTypeDef GPIO_InitStructure;       TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;  NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);              RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4 | RCC_APB1Periph_TIM3,ENABLE);            //时钟使能              /* GPIOA配置:通道PA.6和PA.7作为输出引脚*/          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;     &nbs
    2022-07-26 17:50:34下载
    积分:1
  • C# Hospital MIS 医院业务信息维护系统
    C# Hospital MIS 医院业务信息维护系统,基于VisualC# 2012编写开发的,采用SQLSERVER数据库,内含建库脚本,编译或修改调试本源码前请先重建数据库,并连接好。   本医院业务系统完成的功能有:   导医服务、病人登记、病人预约、前台交费、约品退费、欠费催款、评价管理、医师服务、开医令、药房服务、药品管理、发放药品、退药入库、门诊统计、按科室统计、每日统计、交接班汇总、基本设置、检验设置、检查设置、科室设置、员工值班设置、用户管理、折扣卡设置等功能。
    2022-07-16 15:03:12下载
    积分:1
  • C#操作数据库显示Customers数据表第3-7条记录
    显示Customers数据表第3-7条记录,C#操作数据库显示Customers数据表第3-7条记录,其实做出来例子,才知道,很简单啊,不过需要把数据库先连接好,看如下代码:   private void button1_Click(object sender, EventArgs e)    {//显示Customers数据表第3-7条记录    SqlConnection MyConnection=new SqlConnection();    MyConnection.ConnectionString = @"Data Source =.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";    MyConnection.Open();    SqlCommand MyCommand =new SqlCommand("Select * From Customers ORDER BY CustomerID", MyConnection);    DataSet MySet = new DataSet();    SqlDataAdapter MyAdapter = new SqlDataAdapter(MyCommand);    MyAdapter.Fill(MySet, 2, 5, "Customers");    this.dataGridView1.DataSource=MySet.Tables["Customers"];   }
    2022-03-03 23:39:45下载
    积分:1
  • 二维生成的C(QRCODE)
    二维码(QRCODE)生成的C源代码,比较完整,测试可用
    2022-01-30 22:00:53下载
    积分:1
  • C# 设置制表位控制文本项的输出位置
    C# 设置制表位控制文本项的输出位置,将文字输出成表格的样式:   设置制表位控制文本项的输出位置    string MyText = " 姓名 高等数学 离散数学 数据结构 ";    MyText = MyText + "李开斌 95 81 92 ";    MyText = MyText + "汤小敏 78 84 75 ";    MyText = MyText + "汤柱兰 84 76 82 ";    MyText = MyText + "蒋兰坤 85 92 66 ";    MyText = MyText + "黄 丽 83 91 75 ";    MyText = MyText + "张中姣 75 88 82 ";    FontFamily MyFontFamily = new FontFamily("宋体");    Font MyFont = new Font(MyFontFamily, 10, FontStyle.Regular, GraphicsUnit.Point);    Rectangle MyRect = new Rectangle(25, 70, 280, 110);    SolidBrush MyBrush = new SolidBrush(Color.FromArgb(255, 0, 128, 255));    StringFormat MyFormat = new StringFormat();    float[] MyTabArray = { 60, 80, 80 };    MyFormat.SetTabStops(0, MyTabArray);    e.Graphics.DrawString(MyText, MyFont, MyBrush, MyRect, MyFormat);
    2022-02-28 17:10:41下载
    积分:1
  • C# 设置DataGridView控件中的指定(第二)列只读
    C# 设置DataGridView控件中的指定(第二)列只读,核心代码如下:   private void Form1_Load(object sender, EventArgs e)   {    this.customersTableAdapter.Fill(this.northwindDataSet.Customers);    //设置DataGridView控件中的指定(第二)列只读    this.customersDataGridView.Columns[1].ReadOnly = true;   }
    2022-02-12 23:56:36下载
    积分:1
  • C# 显示DataGridView控件中选定的单元格、行和列
    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);   }
    2022-03-18 13:11:05下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载