如何将选定的datagrid行检索到文本框中 [英] how to retrieve selected row of datagrid into textboxes
本文介绍了如何将选定的datagrid行检索到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Windows应用程序C#,我想在我的文本框中检索选定的行数据。
所以我需要把我的代码放在哪里?哪个事件
以及我需要写什么?
i我正在尝试这个但是这不起作用
i am using windows application C# and i want to retrieve selected row data in my text boxes.
so where i need to put my code?? which event
and what i need to write??
i am trying this but this is not working
private void gvProdctTypName_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
tbProductTypeName.Text = gvProdctTypName.SelectedRows[0].Cells[1].Value.ToString();
}
推荐答案
引用:
所以我需要把我的代码?哪个事件
so where i need to put my code?? which event
尝试添加处理程序到 SelectionChanged
事件
try add a handler to SelectionChanged
event
private void gvProdctTypName_SelectionChanged(object sender, EventArgs e)
{
if (gvProdctTypName.CurrentRow != null)
tbProductTypeName.Text = gvProdctTypName.CurrentRow.Cells[1].Value.ToString();
}
这篇关于如何将选定的datagrid行检索到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文