Results 1 to 7 of 7

Thread: Datagrid to another form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    68

    Datagrid to another form

    Hi, i got a few records displaying in a datagrid. Then if i clicked on one of the record, it should show another form displaying all the respective data in the textbox.
    How do i pass the parameters to the next form?

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    In the form that you want to show - add parameters in the New constructor and then you can pass them in.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or

    Declare an array in a module then assign it values from your form (data form) , then you can use in the entire proj .

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    68
    I dun really understand, can u pls show mi some examples..

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    OK in a module declare this global variable and change number the index of the array to match the number of your actuall data saved to it :

    VB Code:
    1. Public Values(3) As String


    then , in your first form , assign the values to the array elements consecutively as follow :

    VB Code:
    1. Values(0) = "item1"
    2.         Values(1) = "item2"
    3.         Values(2) = "item3"
    4.         Values(3) = "item4"


    lastly , since all data reserved in the array and you can call it from anywhere within your proj , call this array from your second form and assign values to textboxes or whatever you will use as so :

    VB Code:
    1. TextBox1.Text = Values(0)
    2.         TextBox2.Text = Values(1)
    3.         TextBox3.Text = Values(2)
    4.        TextBox4.Text = Values(3)

    I hope this helps .

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    68
    Thanks, but the datagrid is read from the database one lei. How to set the value?

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this something like this :

    VB Code:
    1. Values(0) = DataGrid1.Item(0, 0) ' First row , first column
    2. Values(1) = DataGrid1.Item(0, 1) ' First row , second column
    3. Values(2) = DataGrid1.Item(0, 2) ' First row , third column
    4. Values(3) = DataGrid1.Item(0, 3) ' First row , forth column

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