如何将值传递给gridview

编程入门 行业动态 更新时间:2024-10-26 22:18:25
本文介绍了如何将值传递给gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将选定的datagridview值传递给C#.Net Windows应用程序同一页面中的另一个datagridview. /div>

这是代码段

字符串 ID; 私有 无效 dataGridView1_CellClick(对象发​​件人,DataGridViewCellEventArgs e) { 如果((e.RowIndex == -1)) { MessageBox.Show(" " ); } 其他 { 尝试 { ID = dataGridView1.Rows [e.RowIndex] .Cells [ 0 ].Value.ToString(); } 捕获(例外) { MessageBox.Show(" 错误:" + ex.Message.ToString()); } } }

生成此单元格单击事件,然后尝试以下代码;只需更新要传递的单元格值的单元格值即可. 希望对您有所帮助.

您好, 如biswarup所言,在网格视图的单元格单击事件中执行此操作,当单击特定单元格时,将触发该事件,并在代码中获取该单元格值,并添加到另一个网格中 谢谢 Tapan kumar

i want to pass selected datagridview value to another datagridview in same page in C#.Net Windows Application.any one plz help me ......thanks in advance..

解决方案

Here is the code snippet

String ID; private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if ((e.RowIndex == -1)) { MessageBox.Show(""); } else { try { ID = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); } catch(Exception ex) { MessageBox.Show("Error:" + ex.Message.ToString()); } } }

Generate this cell click event and try this code; just update the cell value which cell value you want to pass. Hope it helps.

Hi, as biswarup told, do this in the cell click event of the grid view, when a particular cell is clicked then that event will be fired and, in code get that cell value, and add to the other grid Thanks Tapan kumar

更多推荐

如何将值传递给gridview

本文发布于:2023-07-22 13:38:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1187982.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!