Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. double click on datagrid and fill in related fields on main form form

double click on datagrid and fill in related fields on main form form

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 7 Offline
    7 Offline
    7prince
    wrote on last edited by
    #1

    Hello, I have a datagrid on one form and I would like to fill in my main form when I double click on any record in the datagrid. How can I do that? I am using VB.NET. thanks, Joseph

    programmer

    P 1 Reply Last reply
    0
    • 7 7prince

      Hello, I have a datagrid on one form and I would like to fill in my main form when I double click on any record in the datagrid. How can I do that? I am using VB.NET. thanks, Joseph

      programmer

      P Offline
      P Offline
      priya_p233
      wrote on last edited by
      #2

      hi, So simple:-D, jst refer all controls name by using relative formname. e.g. if your main form's name is "MainForm" & the form having datagrid where you r going to take records, its name is "RecordForm". then refer datagrid by that form's name e.g. RecordForm.datagrid suppose u hav to fill one value from datagrid's 1st col & 1st row in textbox present on MainForm then write-> textbox1.text= RecordForm.datagrid.item(1,1).value.

      priya

      7 2 Replies Last reply
      0
      • P priya_p233

        hi, So simple:-D, jst refer all controls name by using relative formname. e.g. if your main form's name is "MainForm" & the form having datagrid where you r going to take records, its name is "RecordForm". then refer datagrid by that form's name e.g. RecordForm.datagrid suppose u hav to fill one value from datagrid's 1st col & 1st row in textbox present on MainForm then write-> textbox1.text= RecordForm.datagrid.item(1,1).value.

        priya

        7 Offline
        7 Offline
        7prince
        wrote on last edited by
        #3

        Do I need to do anything regarding double clicking any record on the datagrid? thanks, Joseph

        programmer

        P 1 Reply Last reply
        0
        • 7 7prince

          Do I need to do anything regarding double clicking any record on the datagrid? thanks, Joseph

          programmer

          P Offline
          P Offline
          priya_p233
          wrote on last edited by
          #4

          You write the code in procedure Private Sub MyDatagrid1_RowHeaderMouseDoubleClick(...) ''write code of filling mainform Here ''u can refer to select items of datagrid by Mainform1.textbox1=MyDatagrid1.item(0,e.rowindex).value Mainform1.textbox2=MyDatagrid1.item(1,e.rowindex).value ..... . . ''Like this fill all items of mainform end sub As user clicks on rowheader of datagrid's specific cell ur code will be generated if again any doubt , do ask. I wnt to ask that , Is all of controls on mainform are textboxes?

          priya

          1 Reply Last reply
          0
          • P priya_p233

            hi, So simple:-D, jst refer all controls name by using relative formname. e.g. if your main form's name is "MainForm" & the form having datagrid where you r going to take records, its name is "RecordForm". then refer datagrid by that form's name e.g. RecordForm.datagrid suppose u hav to fill one value from datagrid's 1st col & 1st row in textbox present on MainForm then write-> textbox1.text= RecordForm.datagrid.item(1,1).value.

            priya

            7 Offline
            7 Offline
            7prince
            wrote on last edited by
            #5

            Hi, thank you for your help. It is going good. I am almost done with my application except the one that I am asking. yes. all the fields are textboxes on the main form. I am getting this error when I click on the one of the datagrid cells. Unable to cast object of type 'System.String' to type 'System.Windows.Forms.TextBox'. here is my code: Private Sub FSSCallerRecordsDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles FSSCallerRecordsDataGridView.CellContentClick Form3.HospitalNumberTextBox = FSSCallerRecordsDataGridView.Item(5, e.RowIndex).Value P.S. Form3 is the main form. And the reason I wrote Item(5) is that Hospital number on the datagrid is column number 5. (is it correct) *****Is it necessary I can email you the project? thanks, joseph

            programmer

            T 1 Reply Last reply
            0
            • 7 7prince

              Hi, thank you for your help. It is going good. I am almost done with my application except the one that I am asking. yes. all the fields are textboxes on the main form. I am getting this error when I click on the one of the datagrid cells. Unable to cast object of type 'System.String' to type 'System.Windows.Forms.TextBox'. here is my code: Private Sub FSSCallerRecordsDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles FSSCallerRecordsDataGridView.CellContentClick Form3.HospitalNumberTextBox = FSSCallerRecordsDataGridView.Item(5, e.RowIndex).Value P.S. Form3 is the main form. And the reason I wrote Item(5) is that Hospital number on the datagrid is column number 5. (is it correct) *****Is it necessary I can email you the project? thanks, joseph

              programmer

              T Offline
              T Offline
              TwoFaced
              wrote on last edited by
              #6

              'Form3.HospitalNumberTextBox' should be ---> 'Form3.HospitalNumberTextBox.Text'

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups