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. Delete row from Datagirdview

Delete row from Datagirdview

Scheduled Pinned Locked Moved Visual Basic
help
3 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.
  • Y Offline
    Y Offline
    yetrus
    wrote on last edited by
    #1

    Hi There This is my first post, I need help I've a Datagridview filling from tbx and combobox, I want to put a Checkbox in each row (I don't how) so I want to delete a row checked from the datagridview Please help, I very rookie I'm doing this... Public DRow As DataRow Public Carrito As New DataTable("Detalle") Sub Configuratabla() Dim DC0 As New DataColumn("Item", System.Type.GetType("System.Int64")) Dim DC1 As New DataColumn("Cantidad", System.Type.GetType("System.Int64")) Dim DC2 As New DataColumn("Detalle", System.Type.GetType("System.String")) Dim DC3 As New DataColumn("Valor", System.Type.GetType("System.Int64")) Dim DC4 As New DataColumn("Descuento", System.Type.GetType("System.Int64")) Dim DC5 As New DataColumn("Total", System.Type.GetType("System.Int64")) 'DC4.Expression = "cantidad * Valor " With Carrito.Columns .Add(DC0) .Add(DC1) .Add(DC2) .Add(DC3) .Add(DC4) .Add(DC5) End With GrillaDetalle.DataSource = Carrito End Sub DRow = Carrito.NewRow() DRow(0) = Carrito.Rows.Count + 1 'Item DRow(1) = CInt(TbxCan.Text) 'Cantidad DRow(2) = CbxPro.SelectedItem 'Detalle DRow(3) = Valor1 DRow(4) = CbxDes.SelectedItem 'Descuento DRow(5) = (CInt(TbxCan.Text) Carrito.Rows.Add(DRow) :doh:

    I M 2 Replies Last reply
    0
    • Y yetrus

      Hi There This is my first post, I need help I've a Datagridview filling from tbx and combobox, I want to put a Checkbox in each row (I don't how) so I want to delete a row checked from the datagridview Please help, I very rookie I'm doing this... Public DRow As DataRow Public Carrito As New DataTable("Detalle") Sub Configuratabla() Dim DC0 As New DataColumn("Item", System.Type.GetType("System.Int64")) Dim DC1 As New DataColumn("Cantidad", System.Type.GetType("System.Int64")) Dim DC2 As New DataColumn("Detalle", System.Type.GetType("System.String")) Dim DC3 As New DataColumn("Valor", System.Type.GetType("System.Int64")) Dim DC4 As New DataColumn("Descuento", System.Type.GetType("System.Int64")) Dim DC5 As New DataColumn("Total", System.Type.GetType("System.Int64")) 'DC4.Expression = "cantidad * Valor " With Carrito.Columns .Add(DC0) .Add(DC1) .Add(DC2) .Add(DC3) .Add(DC4) .Add(DC5) End With GrillaDetalle.DataSource = Carrito End Sub DRow = Carrito.NewRow() DRow(0) = Carrito.Rows.Count + 1 'Item DRow(1) = CInt(TbxCan.Text) 'Cantidad DRow(2) = CbxPro.SelectedItem 'Detalle DRow(3) = Valor1 DRow(4) = CbxDes.SelectedItem 'Descuento DRow(5) = (CInt(TbxCan.Text) Carrito.Rows.Add(DRow) :doh:

      I Offline
      I Offline
      ilprincipe
      wrote on last edited by
      #2

      hi, i hope that this can help you : 1-to add checkboxcolumn: Dim mycolumn As New DataGridViewCheckBoxColumn mydatagridview.Columns.Insert(0, mycolumn) 2-to delete row: if mydatagridview.SelectedRows(i).Cells(0).Value=true then mydatagridview.rows.removeat(indexofmayrow) end if

      Il principe ;)

      1 Reply Last reply
      0
      • Y yetrus

        Hi There This is my first post, I need help I've a Datagridview filling from tbx and combobox, I want to put a Checkbox in each row (I don't how) so I want to delete a row checked from the datagridview Please help, I very rookie I'm doing this... Public DRow As DataRow Public Carrito As New DataTable("Detalle") Sub Configuratabla() Dim DC0 As New DataColumn("Item", System.Type.GetType("System.Int64")) Dim DC1 As New DataColumn("Cantidad", System.Type.GetType("System.Int64")) Dim DC2 As New DataColumn("Detalle", System.Type.GetType("System.String")) Dim DC3 As New DataColumn("Valor", System.Type.GetType("System.Int64")) Dim DC4 As New DataColumn("Descuento", System.Type.GetType("System.Int64")) Dim DC5 As New DataColumn("Total", System.Type.GetType("System.Int64")) 'DC4.Expression = "cantidad * Valor " With Carrito.Columns .Add(DC0) .Add(DC1) .Add(DC2) .Add(DC3) .Add(DC4) .Add(DC5) End With GrillaDetalle.DataSource = Carrito End Sub DRow = Carrito.NewRow() DRow(0) = Carrito.Rows.Count + 1 'Item DRow(1) = CInt(TbxCan.Text) 'Cantidad DRow(2) = CbxPro.SelectedItem 'Detalle DRow(3) = Valor1 DRow(4) = CbxDes.SelectedItem 'Descuento DRow(5) = (CInt(TbxCan.Text) Carrito.Rows.Add(DRow) :doh:

        M Offline
        M Offline
        MBCDC
        wrote on last edited by
        #3

        ...or simply add another Column of Type Boolean to your DataTable Dim DC6 As New DataColumn("Delete", System.Type.GetType("System.Boolean")) .Add(DC6) '***initialize Column DRow(6) = false After Binding the DataTable to the DataGridView it will automatically create a CheckBoxColumn out of the DataType Boolean.

        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