首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么双击datagrid中一行,取数据显示在同一页中的各个text文本框中,最好有例子

2012-01-28 
如何双击datagrid中一行,取数据显示在同一页中的各个text文本框中,最好有例子如何双击datagrid中一行,取数

如何双击datagrid中一行,取数据显示在同一页中的各个text文本框中,最好有例子
如何双击datagrid中一行,取数据显示在同一页中的各个text文本框中,最好有例子

[解决办法]
先问个问题,为什么要双击?如果人在的话加我msn:seamanhy@hotmail.com告诉你
[解决办法]
private void dataGrid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hit = this.dataGrid.HitTest(e.X,e.Y) ;

if(hit != null && hit.Type == DataGrid.HitTestType.Cell)
{
if(e.Button==System.Windows.Forms.MouseButtons.Left)
{
if(e.Clicks == 2)
{

DataRowView row = this.m_DataSet.Tables[0].DefaultView[this.dataGrid.CurrentRowIndex] ;
this.txtbox.text=row[ " "].tostring();
this.txtbox.text=row[ " "].tostring();

}

}

}
}
[解决办法]
刚才写错了前面那部分可以不要的!
private void dataGrid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button==System.Windows.Forms.MouseButtons.Left)
{
if(e.Clicks == 2)
{
DataRowView row = this.m_DataSet.Tables[0].DefaultView[this.dataGrid.CurrentRowIndex] ;
this.txtbox.text=row[ " "].tostring();
this.txtbox.text=row[ " "].tostring();
}

}

}
[解决办法]
dataGridView.DataSource 与一 dataBindingSource 绑定:

双击事件 :
DataRow dr =(this.dataBindingSource.Current as DataRowView).Row;

this.textBox1.Text=dr[ "字段名 "].ToString();
...

热点排行