将dataGridView1行中内容显示分别显示到textbox中

pengshidi 2008-03-12 04:44:59
string strsql = "select * from VIP";
SqlConnection conn = new SqlConnection("server=(local) ;database=Logistics;uid=sa;password=;");
SqlCommand cmd = new SqlCommand(strsql, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
这是我的按钮1事件。就是将查到的内容显示在dataGridView1上。
再查询出结果后,我单击某一行,就将行内的内容依次显示在textbox1、textbox2……textbox n
今天分发完了,希望不要见怪。
...全文
112 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengshidi 2008-03-13
  • 打赏
  • 举报
回复
非常感谢各位。
ycagri 2008-03-12
  • 打赏
  • 举报
回复
一种方式是使用数据绑定
另一种方式就是楼上所说的,使用this.dataGridView1.CurrentRow.Cells["列名"].Value.ToString();
nike66 2008-03-12
  • 打赏
  • 举报
回复
textbox1.text = dataGridView1.selectrow[0].cells["列名"].value.tostring();
pengshidi 2008-03-12
  • 打赏
  • 举报
回复
人啊……人啊……
pengshidi 2008-03-12
  • 打赏
  • 举报
回复
这么现实? 没分就没人说,哎……

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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