Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

A string variable and datagrid question

I have a form to show ,add,modify and delete student , also I have datagrid and 2 textboxes and A string varialble (Student_ID), the datagrid contain 3 columes Std_Id,Std_name and std_age
what I want right now is to make the variable (Student_id) have the same Value of the std_id Column(in datagrid)  of the selected row .
1 Solution

try this

    Dim Student_ID As String

    Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
        Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember)
        Dim dr As DataRow = CType(bm.Current, DataRowView).Row
        myx = dr.Item("std_Id")

    End Sub

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now