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
rodchar - 13 Oct 2004 16:39 GMT
btw,
I'm using a collections class to bind to the datagrid.
> Hey all,
>
[quoted text clipped - 6 lines]
> thanks,
> rodchar
rodchar - 13 Oct 2004 18:15 GMT
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
> Hey all,
>
[quoted text clipped - 6 lines]
> thanks,
> rodchar
Sijin Joseph - 14 Oct 2004 05:01 GMT
You need to makre sure that your custom collection supports change
notification by implementing the IBindingList interface.
http://msdn.microsoft.com/library/en-us/dnadvnet/html/vbnet02252003.asp
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> here's some code:
>
[quoted text clipped - 30 lines]
>>thanks,
>>rodchar