-
大小: 73KB文件类型: .zip金币: 2下载: 0 次发布日期: 2021-06-09
- 语言: C#
- 标签: C# winform DataGridView checkbox
资源简介
C#_winform_DataGridView_checkbox复选框_实现单选效果

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
using (SqlConnection con = new SqlConnection())
{
try
{
DataTable dt1 = new DataTable();
dt1.Columns.Add(“编号“ typeof(int));
dt1.Columns.Add(“姓名“ typeof(string));
dt1.Columns.Add(“年龄“ typeof(int));
dt1.Columns.Add(“性别“ typeof(string));
dt1.Rows.Add(1 “小王“ 20 “男“);
dt1.Rows.Add(2 “王小儿“ 30 “男“);
dt1.Rows.Add(3 “李大妈“ 40 “女“);
dt1.Rows.Add(4 “王大嫂“ 50 “女“);
dt1.Rows.Add(5 “李敏“ 60 “女“);
dt1.Rows.Add(6 “老李“ 70 “男“);
dataGridView1.DataSource = dt1;
}
catch { }
}
}
//单击单元格(无论单击的是单元格为内容还是单元格为列头)。
private void dataGridView1_CellClick(object sender DataGridViewCellEventArgs e)
{
//判断是否单击了列头 如果单击了列头e.RowIndex的值为-1;
if (e.RowIndex >= 0)
{
if (e.ColumnIndex == 0)
{
this.txtBianhao.Text = dataGridView1.Rows[e.RowIndex].Cells[“编号“].Value.ToString();
this.txtXingming.Text = dataGridView1.Rows[e.RowIndex].Cells[“姓名“].Value.ToString();
this.txtNianling.Text = dataGridView1.Rows[e.RowIndex].Cells[“年龄“].Value.ToString();
this.txtXingbie.Text = dataGridView1.Rows[e.RowIndex].Cells[“性别“].Value.ToString();
}
}
}
//MultiSelect设置为fasle,用户一次可以多选(按住ctrl键进行选择,不然只为一条)
// 始终在SelectedRows集合中只有一行
//如果没有按住ctrl键进行点击选择无论MultiSelect设置为fasle或true始终选择一行
private void button1_Click(object sender EventArgs e)
{
//选择的行数
MessageBox.Show(“选择的行数:“ + dataGridView1.SelectedRows.Count.ToString());
//选择的行
MessageBox.Show(“选择的行[Index]:“ + dataGridView1.SelectedRows[0].Cells[0].RowIndex.ToString());
}
//MultiSelect设置为true遍历chexkBox选中的行
private void button2_Click(object sender EventArgs e)
{
for (int p = 0; p < dataGridView1.SelectedRows.Count; p++)
{
MessageBox.Show(“选择了第“ + (int.Parse(dataGridView1.SelectedRows[p].Cells[0].RowIndex.ToString()) + 1).ToString() + “行“);
}
}
#region
int Las
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-01-06 15:26 C#_winform_DataGridView_checkbox复选框_实现单选效果\
目录 0 2017-01-06 15:27 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\
目录 0 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\
文件 962 2013-09-14 21:02 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2.sln
文件 28160 2013-09-14 22:50 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2.v11.suo
文件 46592 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2.v12.suo
文件 187 2013-09-14 21:01 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\App.config
目录 0 2013-09-14 21:01 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\
目录 0 2013-09-14 21:07 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\
文件 14848 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
文件 187 2013-09-14 21:01 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe.config
文件 28160 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
文件 24224 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
文件 187 2013-09-14 21:01 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.config
文件 490 2013-03-18 17:00 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
文件 5349 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\Form1.cs
文件 10868 2017-01-06 16:09 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\Form1.Designer.cs
文件 7649 2017-01-06 16:09 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\Form1.resx
目录 0 2013-09-14 21:01 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\
目录 0 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\
文件 865 2017-01-06 15:38 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7311 2017-01-06 15:27 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2013-09-14 21:02 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2013-09-14 21:02 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2013-09-14 21:02 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
目录 0 2013-09-14 21:02 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\TempPE\
文件 2793 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt
文件 977 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache
文件 2211 2017-01-06 15:27 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csprojResolveAssemblyReference.cache
文件 14848 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.exe
文件 180 2017-01-06 16:10 C#_winform_DataGridView_checkbox复选框_实现单选效果\DataGridView摸索\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Form1.resources
............此处省略10个文件信息
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- Winform可视化打印模板设计工具含源码
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
评论
共有 条评论