Results 1 to 4 of 4

Thread: datagrid check

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    151

    datagrid check

    Hi,

    Is it any possible way, the program can check whether user select any row or not?

    If it does, could anyone please tell me how to do it?

    Thanks,
    NewBie

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: datagrid check

    Originally posted by VB.NETNEWBIE
    Hi,

    Is it any possible way, the program can check whether user select any row or not?

    If it does, could anyone please tell me how to do it?

    Thanks,
    NewBie
    you could get an idea about this piece of code to solve your problem.
    VB Code:
    1. Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
    2.         TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, DataGrid1.CurrentCell.ColumnNumber)
    3.     End Sub
    4.  
    5.     Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
    6.         DataGrid1.Select(DataGrid1.CurrentCell.RowNumber)
    7.     End Sub
    Last edited by mar_zim; Sep 24th, 2004 at 01:17 AM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    151
    Hi,

    Thanks for replying,

    how could get the values from each colum in the datagrid, after user selected the row.


    Thanks,
    NewBie

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    Originally posted by VB.NETNEWBIE
    Hi,

    Thanks for replying,

    how could get the values from each colum in the datagrid, after user selected the row.


    Thanks,
    NewBie
    lets assume that you have a datatable

    VB Code:
    1. 'cn is a connection
    2. dim dt as new datatable()
    3. dim da as new sqldataadapter("select * from sampletable",cn)
    4. da.fill(dt)
    5. datagrid1.datasource=dt
    6. 'lets assume that your sample table have 4 colums(id,name,address,telno)
    7. 'in the datagrid click event
    8. textbox1.text = dt.rows(datagrid1.currentcell.rownumber)(0) 'it gets the id
    9. textbox2.text = dt.rows(datagrid1.currentcell.rownumber)(1) 'it gets the name
    10. textbox3.text = dt.rows(datagrid1.currentcell.rownumber)(2) 'it gets the address
    11. textbox4.text = dt.rows(datagrid1.currentcell.rownumber)(3) 'it gets the telno

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