DataGridView数据存入数组?

szds814 2009-10-16 10:33:30
高手指点,如何将DataGridView中某一行的数据存入数组当中?
...全文
646 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
修改一下昵称 2009-10-16
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 yhb417 的回复:]
C# codeint index1=0;int index2=1;for(int i=0;i< DataGridView.Row[0].Cells.Count;i++)
{if(DataGridView.Row[0].Cells[index1].ToString()==DataGridView.Row[0].Cells[index2].ToString())
{//}
}
[/Quote]
不好意思更正一下:

int index1 = 0;
int index2 = 1;

for(int i=0;i < DataGridView.Row[0].Cells.Count;i++)
{
if(DataGridView.Row[index1].Cells[i].ToString()==DataGridView.Row[index2].Cells[i].ToString())
{
//
}
}
lei19890721 2009-10-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 l171147904 的回复:]
string[] aaaa = new string[DataGridView.Row[0].cells.count]
for(int i=0;i < DataGridView.Row[0].cells.count;i++)
{
aaaa[i] = DataGridView.Row[0].cells[i].tostring();
}

遍历行的列
[/Quote]
这个吧
修改一下昵称 2009-10-16
  • 打赏
  • 举报
回复
int index1 = 0;
int index2 = 1;

for(int i=0;i < DataGridView.Row[0].Cells.Count;i++)
{
if(DataGridView.Row[0].Cells[index1].ToString()==DataGridView.Row[0].Cells[index2].ToString())
{
//
}
}
puzhichen 2009-10-16
  • 打赏
  • 举报
回复
嗯 你可以添加个模版列,放个CheckBox到里面,把CheckBox被选中的数据存进去!
[code=C#]
for (int i = 0; i < this.DataGridView1.Rows.Count; i++)
{
CheckBox cbox = (DataGridView1.Rows[i].FindControl("CheckBox1")) as CheckBox;
if (cbox.Checked == true)
{
//这里进行存值!
//sb += (DataGridView1.Rows[i].FindControl("Label1") as Label).Text + ",";
}
}
/code]
SK_Aqi 2009-10-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 l171147904 的回复:]
string[] aaaa = new string[DataGridView.Row[0].cells.count]
for(int i=0;i < DataGridView.Row[0].cells.count;i++)
{
aaaa[i] = DataGridView.Row[0].cells[i].tostring();
}

遍历行的列
[/Quote]
try this
szds814 2009-10-16
  • 打赏
  • 举报
回复
winforms里面的,我要从DataGridView中取出一行值跟另一行进行数值的比对
l171147904 2009-10-16
  • 打赏
  • 举报
回复
dataGridView1.Rows[0].Cells.Count

遍历 第 1行,的数据 存入 数组
l171147904 2009-10-16
  • 打赏
  • 举报
回复
string[] aaaa = new string[DataGridView.Row[0].cells.count]
for(int i=0;i< DataGridView.Row[0].cells.count;i++)
{
aaaa[i] = DataGridView.Row[0].cells[i].tostring();
}

遍历行的列
修改一下昵称 2009-10-16
  • 打赏
  • 举报
回复
DataGridView? 是winforms里面的吗?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧