如何将gridview选择的行值添加到另一个窗体中的文本框 [英] how to get gridview selected row value to text box which is in another windows form
本文介绍了如何将gridview选择的行值添加到另一个窗体中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨......我有两个窗体。
Form1包含3个文本框,提交按钮和Form2包含DataGridView和编辑按钮。
我的问题是我想显示选定的行数据当我单击Form2中的编辑按钮时,各个文本框中的DatagridView
Hi......I have two windows forms.
Form1 contains 3 text boxes, Submit Button and Form2 contains DataGridView and Edit Button.
My question is I want to display selected row data of DatagridView in respective text boxes when I clicked edit button in Form2
推荐答案
将此代码放入编辑按钮单击事件中
string name = dataGridView1.Rows [1] .Cells [1] .Value.ToString(); //这只是一个示例你可以改变索引
将此值作为函数的参数传递
put this code in edit button click event
string name = dataGridView1.Rows[1].Cells[1].Value.ToString(); // this is just a sample u can change the index
pass this value as the argument of a function
这篇关于如何将gridview选择的行值添加到另一个窗体中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文