30/01/2012

How to transfer data from Datagridviewer to Text box?

       As I have posted in my previous post about how to transferring the data from textbox to datagridviewer  extending the same here I am going to give the Vb.Net code for transferring data from datagideviewer to textboxes.For better understanding of these type of vb.net code or database related inquiry the book written by Mike Murach is very good book which is available on amazon with free shipping charge, I will suggest one can  refer.  
To get the data transfer from datagride I have used same windows form and textboxes which I used in my previous post..
the VB.Net code which I have used on the data grid row click event.
If editmode = True Then
             Dim i, j As Integer
                j = e.RowIndex
                i = DataGridView1.CurrentRow.Index
    Me.Txtsno1.Text = Me.DataGridView1.Item(1, j).Value
    Me.TxtMOrderNo.Text = Me.DataGridView1.Item(2, j).Value
    Me.DtpMOrderdate.Value = Me.DataGridView1.Item(3, j).Value
    Me.CbPlaceofDeployment.Text = Me.DataGridView1.Item(4, j).Value
    Me.DtpDeploymentdate.Value = Me.DataGridView1.Item(5, j).Value
    Me.DtpDateofReturn.Value = Me.DataGridView1.Item(6, j).Value
    Me.TxtDeploymentauthorityno.Text = Me.DataGridView1.Item(7, j).Value
    Me.DtpDeploymentauthoritydate.Value Me.DataGridView1.Item(8, j).Value
    Me.TxtPisno.Text = Me.DataGridView1.Item(9, j).Value
    Me.txtname.Text = Me.DataGridView1.Item(10, j).Value
    Me.txtrank.Text = Me.DataGridView1.Item(11, j).Value
    Me.txtcoy.Text = Me.DataGridView1.Item(12, j).Value
    Me.txtaa.Text = Me.DataGridView1.Item(13, j).Value
    Me.txtremarks.Text = Me.DataGridView1.Item(14, j).Value
                            editmode = False
            End If 


Enjoy coding

To understand Vb.Net in better way I will suggest you to have  book written by Anne Prince  "Murach Visual Basic" and that is available on  Amozon and Flipkart