datagrid delete row and refresh

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top