PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 [RESOLVED] click cell datagridview1 and display datagridview2 in label1-VBForums
Results 1 to 3 of 3

Thread: [RESOLVED] click cell datagridview1 and display datagridview2 in label1

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Resolved [RESOLVED] click cell datagridview1 and display datagridview2 in label1

    Hi,
    how to do when i click the cell datagridview1 in the same time will display
    datagridview2 in the label5.text (in the same row)

    my code doesn't work..any wrong?
    Code:
     Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    
    Try
        Dim k As Integer
        Dim g As Integer
        k = DataGridView1.CurrentRow.Index
        g = DataGridView2.CurrentRow.Index
        Label4.Text = CStr(DataGridView1.Item(0, k).Value)
        Label5.Text = CStr(DataGridView2.Item(0, g).Value)
           
    Catch ex As Exception
           MsgBox(ex.ToString)
    End Try

  2. #2
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,183

    Re: click cell datagridview1 and display datagridview2 in label1

    there are few things

    (1) you are triggering the event on datagridview1 cell click
    so there by you are indicating which is the current row & its index & reading that value

    (2) but in your datagridview2 which is the current row ?
    you need direct the application

    some thing like this
    vb Code:
    1. Dim k As Integer
    2.         Dim g As Integer
    3.         k = DataGridView1.CurrentRow.Index
    4.         ' g = DataGridView2.CurrentRow.Index
    5.         Label4.Text = CStr(DataGridView1.Item(0, k).Value)
    6.         Try
    7.             Label5.Text = CStr(DataGridView2.Item(0, k).Value)
    8.         Catch ex As Exception
    9.             Label5.Text = "error while reading the value, " _
    10.             & " row index K may not be available Check number of rows on datagridvie2"
    11.         End Try
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Re: click cell datagridview1 and display datagridview2 in label1

    Thank for your info, solved..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width