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 Clear Grid view in C# [modified]

How to Clear Grid view in C# [modified]

Scheduled Pinned Locked Moved C#
helpcsharpcsswpfwcf
4 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.
  • N Offline
    N Offline
    NK7
    wrote on last edited by
    #1

    Hi I have problem in clearing the grid view. It is binding the old values every time i try to bind any values to the grid. This is the code i have written to clear the grid view Private void clearGridView(DataGridView gView) { gView.SelectAll(); if(gView.SelectedRows.Count== gView.Rows.Count) { gView.Rowsl.Clear(); } foreach(DataGridViewRow dvConnRow in gView.SelectedRows) { gView.Rows.Remove(dvConnRow); } dgView.DataSource=null; } Can any one help me to solve my problem please kesavan -- modified at 3:36 Wednesday 9th May, 2007

    A B 2 Replies Last reply
    0
    • N NK7

      Hi I have problem in clearing the grid view. It is binding the old values every time i try to bind any values to the grid. This is the code i have written to clear the grid view Private void clearGridView(DataGridView gView) { gView.SelectAll(); if(gView.SelectedRows.Count== gView.Rows.Count) { gView.Rowsl.Clear(); } foreach(DataGridViewRow dvConnRow in gView.SelectedRows) { gView.Rows.Remove(dvConnRow); } dgView.DataSource=null; } Can any one help me to solve my problem please kesavan -- modified at 3:36 Wednesday 9th May, 2007

      A Offline
      A Offline
      AFSEKI
      wrote on last edited by
      #2

      gView.Rows.clear(); Hope this helps...

      N 1 Reply Last reply
      0
      • A AFSEKI

        gView.Rows.clear(); Hope this helps...

        N Offline
        N Offline
        NK7
        wrote on last edited by
        #3

        Not working. It is binding the old values to the grid. If I bind the new values it is appending the the existing values.

        kesavan

        1 Reply Last reply
        0
        • N NK7

          Hi I have problem in clearing the grid view. It is binding the old values every time i try to bind any values to the grid. This is the code i have written to clear the grid view Private void clearGridView(DataGridView gView) { gView.SelectAll(); if(gView.SelectedRows.Count== gView.Rows.Count) { gView.Rowsl.Clear(); } foreach(DataGridViewRow dvConnRow in gView.SelectedRows) { gView.Rows.Remove(dvConnRow); } dgView.DataSource=null; } Can any one help me to solve my problem please kesavan -- modified at 3:36 Wednesday 9th May, 2007

          B Offline
          B Offline
          Blumen
          wrote on last edited by
          #4

          setting the datasource to null should clear the grid.

          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