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. Visual Basic
  4. Deleting a DataGrid row ?!

Deleting a DataGrid row ?!

Scheduled Pinned Locked Moved Visual Basic
csharpc++comtoolstutorial
4 Posts 2 Posters 2 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.
  • T Offline
    T Offline
    toxcct
    wrote on last edited by
    #1

    hi coders, i'm perplexed with VB .NET DataGrid... i can't find out how it is possible to remove a selected row from that control. imagine we have a button "suppress a line" and the DataGrid from which the user is able to select a row. what i want is when the button is clicked, i'd like to suppress the selected item from the DGrid... does anyone know how to do that ? thanx in advance


    TOXCCT >>> GEII power
    [toxcct][VisualCalc]

    G 1 Reply Last reply
    0
    • T toxcct

      hi coders, i'm perplexed with VB .NET DataGrid... i can't find out how it is possible to remove a selected row from that control. imagine we have a button "suppress a line" and the DataGrid from which the user is able to select a row. what i want is when the button is clicked, i'd like to suppress the selected item from the DGrid... does anyone know how to do that ? thanx in advance


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      G Offline
      G Offline
      genius123
      wrote on last edited by
      #2

      Hi, You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. eg: dim dtable as new datatable dtable = grid.datasource. dtable.rows.removeat(index) (Use some logic here to pass the row no. i.e. the index) reassign the table. grid.datasource = dtable. do let me know if this helps.

      T 1 Reply Last reply
      0
      • G genius123

        Hi, You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. eg: dim dtable as new datatable dtable = grid.datasource. dtable.rows.removeat(index) (Use some logic here to pass the row no. i.e. the index) reassign the table. grid.datasource = dtable. do let me know if this helps.

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        genius123 wrote: You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. yes, of course, but i didn't know how to catch the index of the selected lineto delete the associated item in my ArrayList... so, thank you for your answer ;)


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        G 1 Reply Last reply
        0
        • T toxcct

          genius123 wrote: You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. yes, of course, but i didn't know how to catch the index of the selected lineto delete the associated item in my ArrayList... so, thank you for your answer ;)


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          G Offline
          G Offline
          genius123
          wrote on last edited by
          #4

          Catching the rowindex is pretty easy. index = datagrid.currentrowindex() if ur using a dataset, delete the row using ds.Tables("tablename").Rows.RemoveAt(index) or a datatable then dtable.rows.removeat(index) and plz try elaborating problems a bit to get exact answers ;)

          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