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. C#
  4. how to bind textbox to dataviewgrid

how to bind textbox to dataviewgrid

Scheduled Pinned Locked Moved C#
tutorial
5 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.
  • G Offline
    G Offline
    ginji20
    wrote on last edited by
    #1

    hi... could someone tell me the codes for this scenario.. if i click on the datagridview for example username if i click that username that username will appear in a label or textbox... thanks...

    S 1 Reply Last reply
    0
    • G ginji20

      hi... could someone tell me the codes for this scenario.. if i click on the datagridview for example username if i click that username that username will appear in a label or textbox... thanks...

      S Offline
      S Offline
      Shorgov
      wrote on last edited by
      #2

      you heard something called CellClick even. Then just get the value of selected cell and giv it to the Text property of your control(Label, TextBox ...) And don't ask your question twice!!!

      Strahil Shorgov

      G 1 Reply Last reply
      0
      • S Shorgov

        you heard something called CellClick even. Then just get the value of selected cell and giv it to the Text property of your control(Label, TextBox ...) And don't ask your question twice!!!

        Strahil Shorgov

        G Offline
        G Offline
        ginji20
        wrote on last edited by
        #3

        sory for asking twice... i know what your saying but i dont know how to get the value of the selected cell... can you tell me...

        S 1 Reply Last reply
        0
        • G ginji20

          sory for asking twice... i know what your saying but i dont know how to get the value of the selected cell... can you tell me...

          S Offline
          S Offline
          Shorgov
          wrote on last edited by
          #4

          Try this tbUserName.Text = gvUsers.SelectedCells[0].Value.ToString();

          Strahil Shorgov

          K 1 Reply Last reply
          0
          • S Shorgov

            Try this tbUserName.Text = gvUsers.SelectedCells[0].Value.ToString();

            Strahil Shorgov

            K Offline
            K Offline
            Kjetil Svendsen
            wrote on last edited by
            #5

            Try the CellEnter event:

            void dataGridView_CellEnter(object sender, DataGridViewCellEventArgs e)
            {
            if (((DataGridView)sender)[e.ColumnIndex, e.RowIndex].Value != System.DBNull.Value)
            Textbox.Text = ((DataGridView)sender)[e.ColumnIndex, e.RowIndex].Value.ToString();

            }

            Kjetil

            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