急~如何从datagridview中把被选中CheckBox的多行存入到LIST中? 本帖最后由 huafeihua116 于 2010-08-20 17:41:41 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 通过row[index]去取得这一行的数据啊,然后保存 //判断在第一列Checkbox栏被选中的项目; if (row.Cells[0].Value != null && (bool)row.Cells[0].Value == true) { //写到这里就不会写了; }你这里判断了如果是选中了就获取这一行的数据吗这一行的数据也是 row.Cells[1].Value ,row.Cells[2].Value ,row.Cells[3].Value 这样取得啊存放到比如TrcLaneInfoData中就用 TrcLaneInfoData data = new TrcLaneInfoData();data.xxx = row.Cells[1].Value foreach (DataGridViewRow dr in this.dataGridView1.Rows) { try { DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0]; if ((bool)cbx.FormattedValue) { str+= dr.Cells[1].Value; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } 如何将一个BYTE转换为颜色。 Linq中的Min如何用? 一个TabControl控件的问题 求救,如何在C#中模拟DELETE键 datatable.select() 方法 比较问题 求一个简单算法 微软的中文MSDN翻译的太烂了,看了半天还是不懂,大家帮帮忙啊!!!!! C#编写的类似QQ即时通讯软件怎么在局域网里测试? 关于连接数据库 dev的gridcontrol获取组计行的问题。 C# 读取自身exe中的资源文件 sendmessage发送字符串到记事本
if (row.Cells[0].Value != null && (bool)row.Cells[0].Value == true)
{
//写到这里就不会写了;
}
你这里判断了如果是选中了就获取这一行的数据吗
这一行的数据也是 row.Cells[1].Value ,row.Cells[2].Value ,row.Cells[3].Value 这样取得啊存放到比如TrcLaneInfoData中就用
TrcLaneInfoData data = new TrcLaneInfoData();
data.xxx = row.Cells[1].Value
{
try
{
DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
if ((bool)cbx.FormattedValue)
{
str+= dr.Cells[1].Value;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}