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. Datagridview

Datagridview

Scheduled Pinned Locked Moved C#
databasetutorial
2 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.
  • Y Offline
    Y Offline
    yesu prakash
    wrote on last edited by
    #1

    hi, How to add a blank row in the last index when click on the datagridview. When we type any character in any cell a new blank row is generated by default, likewise i need to generate in any click. AllowUsertoaddrow is set to true. Thankyou

    D 1 Reply Last reply
    0
    • Y yesu prakash

      hi, How to add a blank row in the last index when click on the datagridview. When we type any character in any cell a new blank row is generated by default, likewise i need to generate in any click. AllowUsertoaddrow is set to true. Thankyou

      D Offline
      D Offline
      David Ewen
      wrote on last edited by
      #2

      This will create a new row when the current new row gets clicked. I could see how this may be annoying for users though but I will assume you have your reasons.

      public Form1()
      {
      InitializeComponent();

      dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1\_CellClick);
      

      }

      private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
      {
      DataGridView dataGridView = sender as DataGridView;
      if(dataGridView.Rows[e.RowIndex].IsNewRow)
      {
      int newRowIndex = dataGridView.Rows.Add();
      dataGridView.CurrentCell = dataGridView.Rows[newRowIndex].Cells[e.ColumnIndex];
      }
      }

      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