CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Datagrid

  1. #1
    Join Date
    Sep 2002
    Posts
    47

    Datagrid

    Hi

    I would like to know how to put the data in the dbgrid in some text box. I want to be able to click on a row and the data in each cell will appear in their textbox.

    How can i do that ?

    thanks a lot
    Alexandre

  2. #2
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Cool

    For example, you have three text box and data grid with three column
    See this code:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    AddHandler DataGrid1.CurrentCellChanged, AddressOf Grid_CurCellChange
    End Sub

    Protected Sub Grid_CurCellChange(ByVal sender As Object, ByVal e As EventArgs)
    TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0).ToString()
    TextBox2.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 1).ToString()
    TextBox3.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 2).ToString()
    End Sub

    This code fill data from column 1 to texbox1, from column 2 to textbox2 and from column 3 to textbox3
    Andy Tower

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured