how to fill all controls with a record by selecting a record from datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • techno58
    New Member
    • Dec 2009
    • 3

    how to fill all controls with a record by selecting a record from datagridview

    In my form i want to be able to fill all my controls with a particular record by selecting that record from my datagridview.If i select a particular record after clicking on it all my controls like textbox etc will be filled with that specific record.
    Can i do this without using binding context?
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Yes. There are several events on the DataGridView class that you can use... RowEnter looks promising, or perhaps SelectionChange d? Whichever one suits your needs, you should be able to set it up so that you fill your controls with the data from the selected row or cell

    Comment

    • techno58
      New Member
      • Dec 2009
      • 3

      #3
      Thanks for the quick reply .I know that i can use those events,but my point how am i supposed to tell which row.How am i supposed to say that i have selected that particular row

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        put this code in DataGrid_RowCha nged or some relevant event and then type this code...

        Code:
        if(DataGrid1.SelectedRows.Count!=-1)
        {
        DataRow dr=DataGrid1.SelectedRows[0];
        }
        Now Loop through dr and then get all the values

        Comment

        • GaryTexmo
          Recognized Expert Top Contributor
          • Jul 2009
          • 1501

          #5
          I'd also be willing to bet that the row comes through in the event arguments... depending on what level of detail comes through.

          Comment

          Working...