C#上的datagrid [英] datagrid on c#
本文介绍了C#上的datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个datagridview容器数据.当我双击datagridview的单元格时.它显示了包含该记录内容的表单.如何将记录内容分配给表单上的文本框?谢谢
I have a datagridview that container data. When I double click on cell of datagridview. It show a form that contain content of this record. How to assign content of record to textboxes on form? Thanks
推荐答案
请参见此处 [ ^ ].
对于名称为_dataGridV
的datagriview控件,我将执行以下操作以将记录中的数据分配给Windows窗体上的文本框..
For a datagriview control with the name :_dataGridV
, I would do the following to assign the data on the record to a textbox on a windows form..
textbox1.Text =_dataGridV.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();
// and fix it in the event handler code for click or doubleClick
但是,如果您要根据选择的行从数据库中获取表单数据,则需要在此处使用单击的记录的主键来实现一些逻辑,然后使用选择查询或存储过程来获取数据从数据库使用主键更改为以下形式
but if you''re getting your Form data from a database based on the row you select then you would need to implement some logic here using the primary key of the record you click and then use a select query or stored procedure to get the data from the database using the primary key unto the form
这篇关于C#上的datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文