|
Namespace Controls.Form
Public Class ManageDataListItems
Implements IManageItems
Sub New(items As Object)
If Not TypeOf items Is Data.List.DataList Then Throw New InvalidCastException("Must be a DataList")
Me.Items = items
End Sub
Public Property NewItem As CreateNewItem Implements IManageItems.NewItem ' Ignored
Public Property Items As Object Implements IManageItems.Items
Public Property CanAdd As Boolean = True Implements IManageItems.CanAdd
Public Property CanDelete As Boolean = True Implements IManageItems.CanDelete
Public Property List As Data.List.DataList
Public Function Add() As Object Implements IManageItems.Add
If Not CanAdd Then Return Nothing
With DirectCast(Items, Data.List.DataList)
Return .Rows.NewRow()
End With
End Function
Public Sub Delete(index As Integer) Implements IManageItems.Delete
If Not CanDelete Then Return
With DirectCast(Items, Data.List.DataList)
.Rows.RemoveAt(index)
End With
End Sub
Public Function View() As ComponentModel.ICollectionView Implements IManageItems.View
Return CollectionViewSource.GetDefaultView(DirectCast(Items, Data.List.DataList).Rows)
End Function
End Class
End Namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I enjoy my wife, living in the woods, my 7 dogs, and learning new things. I like to play with UI stuff and model based coding.