what is vb.net code for delete a record in datagrid using vb.net windows application?

Sathyanarayana

what is vb.net code for delete a record in datagrid using vb.net windows application?

by Sathyanarayana » Tue, 26 May 2015 00:37:36

what is vb.net code for delete a record in datagrid using vb.net windows application.

element10

what is vb.net code for delete a record in datagrid using vb.net windows application?

by element10 » Thu, 28 May 2015 01:38:37

Code Snippet

Private Sub cmdRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdRemove.Click

With Me.dgvMain

For Each r As DataGridViewRow In .SelectedRows

.Rows.RemoveAt(r.Index)

Next

End With

End Sub


element10

what is vb.net code for delete a record in datagrid using vb.net windows application?

by element10 » Fri, 29 May 2015 03:40:39

I'm sorry I did not realize you were using a System.Windows.Forms.DataGrid, my code uses the newer control System.Windows.Forms.DataGridView which is based on the DataGrid control. You can change to the newer control by finding your DataGrid declaration in YourFile.Designer.vb change the declaration to DataGridView.

Sathyanarayana

what is vb.net code for delete a record in datagrid using vb.net windows application?

by Sathyanarayana » Sat, 30 May 2015 02:39:38

hai element109

can't delete any record from datagrid using ur code,i am very new to vb.net windows so plz help...

regards

sathyanarayanan


spott

what is vb.net code for delete a record in datagrid using vb.net windows application?

by spott » Sun, 31 May 2015 04:41:40

Are you using VB Express or an earlier version of VB.NET. If you are using VB Express its highly likely your using a datagridview control. If so, are you using databinding (did you set the datasource property).

Do you want to delete the row from the grid but next time the grid is loaded want the data to re-appear or do you want to remove the data permanently from the database.


Gavin Jin - MSF

what is vb.net code for delete a record in datagrid using vb.net windows application?

by Gavin Jin - MSF » Mon, 01 Jun 2015 06:43:42

Hi,we can delete the datatable row ,then it will be reflected on the datagrid.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Try

ds.Tables(0).Rows.RemoveAt(Me.DataGrid1.CurrentRowIndex)

da.Update(ds)

MessageBox.Show("success!")

Catch ex As Exception

MessageBox.Show("fail")

End Try

End Sub

Hope it helps

Regards.



Feng Chen - MSF

what is vb.net code for delete a record in datagrid using vb.net windows application?

by Feng Chen - MSF » Tue, 02 Jun 2015 05:42:41

Hi Sathyanarayanan,

Move the thread from Visual Basic Express Edition in order to get better answers.

Thanks for your understanding!



GNSuja

what is vb.net code for delete a record in datagrid using vb.net windows application?

by GNSuja » Wed, 03 Jun 2015 07:44:43

Hi !

I am Sujay .I need to your help.In this code error message in vs2005. "(Me.DataGrid1.CurrentRowIndex)" .Please help me.

I want to delete and update datagrid value.

Please help me.

Thanks.


Try

ds.Tables(0).Rows.RemoveAt(Me.DataGrid1.CurrentRowIndex)

da.Update(ds)

MessageBox.Show("success!")

Catch ex As Exception

MessageBox.Show("fail")

End Try