datagrid delete row and refresh

G

Guest

Hey all,

I have a winform datagrid and when I press delete to delete a row , the
collection item is removed but the datagrid still shows the record. unless i
click somewhere on the datagrid and then the record disappears.

how do i put the two together where when i hit delete the datagrid is updated?

thanks,
rodchar
 
G

Guest

here's some code:

Dim sq As Square
Dim squares As SquareCollection

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataGrid1.SetDataBinding(squares, "squares")
squares = New SquareCollection
squares.Create(10)
squares.Create(20)
squares.Create(30)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DataGrid1.DataSource = squares
End Sub

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
squares.RemoveAt(DataGrid1.CurrentRowIndex)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top