如何在数据网格中选择一行

编程入门 行业动态 更新时间:2024-10-28 10:33:14
本文介绍了如何在数据网格中选择一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好 我在选择数据网格中的一行时遇到问题.我在下面的代码中使用当前行索引.但它不起作用.

Hi everyone I am facing problem in selecting a row in data grid . i am using current row index in following code. but it is not working.

Private Sub dgvEmployeedetails_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvEmployeedetails.CellContentClick Public Event RowCommand As GridViewCommandEventHandler Dim i As Integer i = dgvEmployeedetails.CurrentRowIndex() dgvEmployeedetails.Item(.CurrentRowIndex, 0) dgvEmployeedetails.Item(.CurrentRowIndex, 1) End Sub where dgvEmployeedetails is data grid name. in which i have 2 colums which is number and name. my requirement is i should be able to select both columns when i click with mouse pointer in data grid and all data related to it must be retrived from database in appropiate fields. kindly help me how to code. to fulfil my above requirement

推荐答案

Dim ContactName As String ContactName = dgContactList.CurrentRow.Cells(0).Value

其中cells(0)是您想要的列号,请记住0是第一列

where cells(0) is the column number that you want, remembering that 0 is the first column

更多推荐

如何在数据网格中选择一行

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

发布评论

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

>www.elefans.com

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