Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15655

Deleting a row from the data source (datatable) of a datagridview

$
0
0
Hi,
I am struggling to delete a row from a datatable that I have bound to my DGV (datagridview).
The DGV is not full row selection thing and users can click only on one cell at time.
I can delete the row from the DGV but the row is not actually deleted form the datatable.

Will someone please help me to figure it out?

Thanks.
here my tires:


Code:

     
DataGridView1.Rows.RemoveAt(DataGridView1.CurrentCell.RowIndex)' Obviously nothing is happening to the datatabel here
''

This is how I bind the datatable to the DGV:

Code:

  Dim MyBindingSource As New BindingSource()
        If Shared_AlertTable_Local.Rows.Count > 0 Then
            Dim tempDT As DataTable = Shared_AlertTable_Local.DefaultView.ToTable(True, "Interval", "ToBeNotified", "Escalation", "WhomToEscalate", "HowToAlert")

            MyBindingSource.DataSource = tempDT
            With DataGridView1
                .DataSource = MyBindingSource
                .RowHeadersVisible = False
                .EnableHeadersVisualStyles = False
                .AllowUserToAddRows = False
                .BackgroundColor = Color.White
                .ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
            End With
            EnableDoubleBuffered(DataGridView1)
        Else
            Call RemoveBindingSourceForDGV(DataGridView1)
        End If


Viewing all articles
Browse latest Browse all 15655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>