在一个DataGrid中显示了一个表的三列数据
我想在点DataGrid时候,自动把在DataGrid上所选的一行填到三个文本框里
谁能帮我写一段代码实现,谢谢了!
我想在点DataGrid时候,自动把在DataGrid上所选的一行填到三个文本框里
谁能帮我写一段代码实现,谢谢了!
解决方案 »
- 怎么从listbox1中取选中的值给 texbox1?
- Winform如何记住修改密码,使得下次登陆密码为这次的修改密码啊?
- 关于NAT穿透
- 业务实体绑定到界面控件的问题
- picturebox button 放在一起时候,TAB只可以选者button,我怎么选择PICTUREBOX`~
- datagird让内容自动换行
- 高手指点!为什么我在下拉列表中添加了些项后,在selectedchange事件中添加些代码测试,发现始终选的是第一项.
- 怎么在VS 2005插入flash呢?
- C#中关于自定义控件的属性添加
- 程序自动启动
- 拖放功能如何实现啊?
- 在报表里设置了两个“参数字段”请问如何向参数字段传值,多谢
textBox2.text=e.Item.Cells[1].Text.ToString();Cells[0]是第一个单元格
Cells[1]是第二个单元格
textBox2.text=datagrig[i, 1];
textBox3.text=datagrig[i, 2];
textBox2.text=datagrig[i, 1];
textBox3.text=datagrig[i, 2];
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
//清空当前zsmx的信息
this.dataSet11.Tables["zsmx"].Clear();
//根据clch查询得到dataGrid2要显示的值
string s1=(string)this.dataSet11.Tables["zslc"].Rows[this.dataGrid1.CurrentRowIndex][4];
this.sqlSelectCommand2.Parameters["@clch"].Value=s1;
this.sqlDataAdapter2.Fill(this.dataSet11);
//重新绑定dataGrid2,这样才能适时更新
this.dataGrid2.SetDataBinding(this.dataSet11,"zsmx");
}
只有在第二次点的时候才能可以,不过真谢谢你!
{
//更新数据库中的信息
string strName = e.ItemCells[1].Text;
int intChines = Int32.Parse(((TextBox)e.Item.Cells[2].Controls[0].Text)); //e.Item.Cells[3].Controls[0]表示的是当前激发事件表格行的第三个单元格的第一个控件.在DataGrid的编辑应用中这个控件是TextBox
int intMath = Int32.Parse(((TextBox)e.Item.Cells[3].Controls[0]).Text);
int intEnglist = Int32.Parse(((TextBox)e.Item.Cells[4].Controls[0]).Text);
//更新数据库中的数据
string strUpdate = "Update Score Set Chinese=" + intChinese + ",Math="+intMath + ",English= "intEnglish + "Where Name ="
'"+strName+"'";
OleDbCommand MyComm = new OleDbCommand(strUpdate,MyConn);
MyComm.ExecuteNonQuery();
score.EditItemIndex = -1;
BindGrid(); //重新绑定DataGrid控件
}
{
DataGrid dg = (DataGrid)sender;
DataGridCell myCell = dg.CurrentCell;
MessageBox.Show(myCell.ToString());
}