c#怎么双击datagridview把那行的数据传递到另一个窗体的文本框控件

2024-01-14 22:59:03
推荐回答(4个)
回答1:

我怎么感觉你提问过。

在接受文本框内容的窗体txtForm这么写:

public static String txt="";
void loadnewform()
{
   dataForm df=new dataForm();
   df.ShowDialog();  //不是show,否则没反应
}

在dataGridview的窗体dataForm这样写:

private void dataGridView1_cellClick(object sender,EventArgs e)
{
   txtForm.txt=dataGridView1.Cells[e.Index].Columns["列名"].Values.ToString();
}

这样你鼠标点哪,就显示你指定列名下鼠标选中行的值

回答2:

目测应该是在列表上双击,显示这条数据的明细信息。
双击时,先取得所在的行对象。然传给明细窗口。

回答3:

通过datagridview双击事件实现获取datagridview数据,代码如下:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{

// 取得当前单元格内容
Console.WriteLine(DataGridView1.CurrentCell.Value);
// 取得当前单元格的列 Index
Console.WriteLine(DataGridView1.CurrentCell.ColumnIndex);
// 取得当前单元格的行 Index
Console.WriteLine(DataGridView1.CurrentCell.RowIndex);

}

回答4:

e.Item.Attributes.Add ("ondblclick","javascript:return window.open('打开的窗口.aspx?id=" +e.Item.Cells[0].Text + "','','toolbar=no,scrollbars=yes,width=750,height=550,resizable=yes');");

在项绑定事件里面 加上这个 ,然后根据你实际情况 ,添加参数,就是利用页面间request传值,
然后那边加载的时候再从request获取,再绑定就行了