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. copying row in datagridview

copying row in datagridview

Scheduled Pinned Locked Moved C#
questionhelp
3 Posts 2 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.
  • P Offline
    P Offline
    phantanagu
    wrote on last edited by
    #1

    I have a stupid question like this How do I copy a row and paste it into a new row at run time? I know I can use the getClipboardContent method and work with this content. It seems to be a bad way, even unexpected result. Help me solve my problem . Thanks in advance

    It seem to be a solution or an answer.

    S P 2 Replies Last reply
    0
    • P phantanagu

      I have a stupid question like this How do I copy a row and paste it into a new row at run time? I know I can use the getClipboardContent method and work with this content. It seems to be a bad way, even unexpected result. Help me solve my problem . Thanks in advance

      It seem to be a solution or an answer.

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      The ClipboardContent Method is ok. pls put your code we will help you in this regard.

      Regards, Satips.

      1 Reply Last reply
      0
      • P phantanagu

        I have a stupid question like this How do I copy a row and paste it into a new row at run time? I know I can use the getClipboardContent method and work with this content. It seems to be a bad way, even unexpected result. Help me solve my problem . Thanks in advance

        It seem to be a solution or an answer.

        P Offline
        P Offline
        phantanagu
        wrote on last edited by
        #3

        My code is here private void copyToolStripMenuItem_Click(object sender, EventArgs e) { DataObject obj = dataGridView1.GetClipboardContent(); str = obj.GetText(TextDataFormat.CommaSeparatedValue).Substring(1).Split(','); } private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { try { DataGridViewRow dgvRow = dataGridView1.Rows[0]; for (int i = 0; i < str.GetLength(0); i++) dgvRow.Cells[i].Value = str[i]; dataGridView1.Rows.Add(dgvRow); } catch (Exception ex) { } } But it throws an exception "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound" I am very confused. Kindly help me. Thanks

        It seem to be a solution or an answer.

        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