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. incorrect sorting in dataGridView

incorrect sorting in dataGridView

Scheduled Pinned Locked Moved C#
algorithms
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.
  • K Offline
    K Offline
    KLASTER
    wrote on last edited by
    #1

    Hello there I've put dataGridView control on the Form and i've written this code: private void Form1_Load(object sender, EventArgs e) { dataGridView1.Columns.Add("Main", "Main"); dataGridView1.Rows.Add(3); dataGridView1[0, 0].Value = "A"; dataGridView1[0, 1].Value = "B"; dataGridView1[0, 2].Value = "F"; dataGridView1[0, 3].Value = "ABC"; } So, when i try to sort it (clicking on the header of the table) - the last row ("ABC") is every time the last:confused:

    You can go a long way with a smile. You can go a lot farther with a smile and a gun. (C) Al Capone

    A 1 Reply Last reply
    0
    • K KLASTER

      Hello there I've put dataGridView control on the Form and i've written this code: private void Form1_Load(object sender, EventArgs e) { dataGridView1.Columns.Add("Main", "Main"); dataGridView1.Rows.Add(3); dataGridView1[0, 0].Value = "A"; dataGridView1[0, 1].Value = "B"; dataGridView1[0, 2].Value = "F"; dataGridView1[0, 3].Value = "ABC"; } So, when i try to sort it (clicking on the header of the table) - the last row ("ABC") is every time the last:confused:

      You can go a long way with a smile. You can go a lot farther with a smile and a gun. (C) Al Capone

      A Offline
      A Offline
      Anil Ch
      wrote on last edited by
      #2

      Hi, Make number of row 1 more then acutal rows. dataGridView1.Rows.Add(4) I think internally it take the last rows as newRow and doesnot considers while sorting. Hope this helps. Regards, Anil Ch

      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