如何从网格到文本框获取值 [英] how to get values from grid to textbox

查看:78
本文介绍了如何从网格到文本框获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview.on点击一个特定的单元格我需要将gridview中的值以相同的形式从文本框中获取。如何做到这一点???

解决方案

< blockquote>使用 GridView 的属性来提取相关项(必要时转换为字符串)。使用 TextBox Text 属性来显示结果。


你可以使用 CellContentClick DataGridView事件。

希望这会对你有帮助。



  private   void  DataGridView1_CellContentClick( object  sender ,DataGridViewCellEventArgs e)
{
txtName.text = DataGridView1.Rows [e.RowIndex] .Cells [e.ColumnIndex] .Value.ToString();

}


I have a gridview.on clicking a particular cell i need to take the values from gridview to textboxes in same form..how to do that???

解决方案

Use the properties of the GridView to extract the relevant item (converting to a string if necessary). Use the Text property of the TextBox to display the result.


you can use CellContentClick Event of DataGridView.
Hope this will help you.

private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
     txtName.text=DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

}


这篇关于如何从网格到文本框获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆