Click here to Skip to main content
15,892,059 members
Articles / Desktop Programming / Windows Forms

Edit Almost Anything in a DataGrid

Rate me:
Please Sign up or sign in to vote.
4.92/5 (52 votes)
27 Feb 20054 min read 353.5K   7.3K   256  
Allow your DataGrid to edit pictures and a whole range of other data types.
'------------------------------------------------------------------------------
' <autogenerated>
'     This code was generated by a tool.
'     Runtime Version: 1.1.4322.573
'
'     Changes to this file may cause incorrect behavior and will be lost if 
'     the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports System
Imports System.Data
Imports System.Runtime.Serialization
Imports System.Xml


<Serializable(),  _
 System.ComponentModel.DesignerCategoryAttribute("code"),  _
 System.Diagnostics.DebuggerStepThrough(),  _
 System.ComponentModel.ToolboxItem(true)>  _
Public Class Form1_Field
    Inherits DataSet
    
    Private tableField As FieldDataTable
    
    Private tableContributors As ContributorsDataTable
    
    Private relationField_Contributors As DataRelation
    
    Public Sub New()
        MyBase.New
        Me.InitClass
        Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
        AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
        AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
    End Sub
    
    Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
        MyBase.New
        Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(System.String)),String)
        If (Not (strSchema) Is Nothing) Then
            Dim ds As DataSet = New DataSet
            ds.ReadXmlSchema(New XmlTextReader(New System.IO.StringReader(strSchema)))
            If (Not (ds.Tables("Field")) Is Nothing) Then
                Me.Tables.Add(New FieldDataTable(ds.Tables("Field")))
            End If
            If (Not (ds.Tables("Contributors")) Is Nothing) Then
                Me.Tables.Add(New ContributorsDataTable(ds.Tables("Contributors")))
            End If
            Me.DataSetName = ds.DataSetName
            Me.Prefix = ds.Prefix
            Me.Namespace = ds.Namespace
            Me.Locale = ds.Locale
            Me.CaseSensitive = ds.CaseSensitive
            Me.EnforceConstraints = ds.EnforceConstraints
            Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
            Me.InitVars
        Else
            Me.InitClass
        End If
        Me.GetSerializationData(info, context)
        Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
        AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
        AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
    End Sub
    
    <System.ComponentModel.Browsable(false),  _
     System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)>  _
    Public ReadOnly Property Field As FieldDataTable
        Get
            Return Me.tableField
        End Get
    End Property
    
    <System.ComponentModel.Browsable(false),  _
     System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)>  _
    Public ReadOnly Property Contributors As ContributorsDataTable
        Get
            Return Me.tableContributors
        End Get
    End Property
    
    Public Overrides Function Clone() As DataSet
        Dim cln As Form1_Field = CType(MyBase.Clone,Form1_Field)
        cln.InitVars
        Return cln
    End Function
    
    Protected Overrides Function ShouldSerializeTables() As Boolean
        Return false
    End Function
    
    Protected Overrides Function ShouldSerializeRelations() As Boolean
        Return false
    End Function
    
    Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
        Me.Reset
        Dim ds As DataSet = New DataSet
        ds.ReadXml(reader)
        If (Not (ds.Tables("Field")) Is Nothing) Then
            Me.Tables.Add(New FieldDataTable(ds.Tables("Field")))
        End If
        If (Not (ds.Tables("Contributors")) Is Nothing) Then
            Me.Tables.Add(New ContributorsDataTable(ds.Tables("Contributors")))
        End If
        Me.DataSetName = ds.DataSetName
        Me.Prefix = ds.Prefix
        Me.Namespace = ds.Namespace
        Me.Locale = ds.Locale
        Me.CaseSensitive = ds.CaseSensitive
        Me.EnforceConstraints = ds.EnforceConstraints
        Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
        Me.InitVars
    End Sub
    
    Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
        Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
        Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
        stream.Position = 0
        Return System.Xml.Schema.XmlSchema.Read(New XmlTextReader(stream), Nothing)
    End Function
    
    Friend Sub InitVars()
        Me.tableField = CType(Me.Tables("Field"),FieldDataTable)
        If (Not (Me.tableField) Is Nothing) Then
            Me.tableField.InitVars
        End If
        Me.tableContributors = CType(Me.Tables("Contributors"),ContributorsDataTable)
        If (Not (Me.tableContributors) Is Nothing) Then
            Me.tableContributors.InitVars
        End If
        Me.relationField_Contributors = Me.Relations("Field_Contributors")
    End Sub
    
    Private Sub InitClass()
        Me.DataSetName = "Form1_Field"
        Me.Prefix = ""
        Me.Namespace = ""
        Me.Locale = New System.Globalization.CultureInfo("en-IE")
        Me.CaseSensitive = false
        Me.EnforceConstraints = false
        Me.tableField = New FieldDataTable
        Me.Tables.Add(Me.tableField)
        Me.tableContributors = New ContributorsDataTable
        Me.Tables.Add(Me.tableContributors)
        Dim fkc As ForeignKeyConstraint
        fkc = New ForeignKeyConstraint("Field_Contributors", New DataColumn() {Me.tableField.idColumn}, New DataColumn() {Me.tableContributors.FieldColumn})
        Me.tableContributors.Constraints.Add(fkc)
        fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None
        fkc.DeleteRule = System.Data.Rule.Cascade
        fkc.UpdateRule = System.Data.Rule.Cascade
        Me.relationField_Contributors = New DataRelation("Field_Contributors", New DataColumn() {Me.tableField.idColumn}, New DataColumn() {Me.tableContributors.FieldColumn}, false)
        Me.Relations.Add(Me.relationField_Contributors)
    End Sub
    
    Private Function ShouldSerializeField() As Boolean
        Return false
    End Function
    
    Private Function ShouldSerializeContributors() As Boolean
        Return false
    End Function
    
    Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
        If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then
            Me.InitVars
        End If
    End Sub
    
    Public Delegate Sub FieldRowChangeEventHandler(ByVal sender As Object, ByVal e As FieldRowChangeEvent)
    
    Public Delegate Sub ContributorsRowChangeEventHandler(ByVal sender As Object, ByVal e As ContributorsRowChangeEvent)
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class FieldDataTable
        Inherits DataTable
        Implements System.Collections.IEnumerable
        
        Private columnid As DataColumn
        
        Private columnName As DataColumn
        
        Private columnDescription As DataColumn
        
        Friend Sub New()
            MyBase.New("Field")
            Me.InitClass
        End Sub
        
        Friend Sub New(ByVal table As DataTable)
            MyBase.New(table.TableName)
            If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
                Me.CaseSensitive = table.CaseSensitive
            End If
            If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
                Me.Locale = table.Locale
            End If
            If (table.Namespace <> table.DataSet.Namespace) Then
                Me.Namespace = table.Namespace
            End If
            Me.Prefix = table.Prefix
            Me.MinimumCapacity = table.MinimumCapacity
            Me.DisplayExpression = table.DisplayExpression
        End Sub
        
        <System.ComponentModel.Browsable(false)>  _
        Public ReadOnly Property Count As Integer
            Get
                Return Me.Rows.Count
            End Get
        End Property
        
        Friend ReadOnly Property idColumn As DataColumn
            Get
                Return Me.columnid
            End Get
        End Property
        
        Friend ReadOnly Property NameColumn As DataColumn
            Get
                Return Me.columnName
            End Get
        End Property
        
        Friend ReadOnly Property DescriptionColumn As DataColumn
            Get
                Return Me.columnDescription
            End Get
        End Property
        
        Public Default ReadOnly Property Item(ByVal index As Integer) As FieldRow
            Get
                Return CType(Me.Rows(index),FieldRow)
            End Get
        End Property
        
        Public Event FieldRowChanged As FieldRowChangeEventHandler
        
        Public Event FieldRowChanging As FieldRowChangeEventHandler
        
        Public Event FieldRowDeleted As FieldRowChangeEventHandler
        
        Public Event FieldRowDeleting As FieldRowChangeEventHandler
        
        Public Overloads Sub AddFieldRow(ByVal row As FieldRow)
            Me.Rows.Add(row)
        End Sub
        
        Public Overloads Function AddFieldRow(ByVal Name As String, ByVal Description As String) As FieldRow
            Dim rowFieldRow As FieldRow = CType(Me.NewRow,FieldRow)
            rowFieldRow.ItemArray = New Object() {Nothing, Name, Description}
            Me.Rows.Add(rowFieldRow)
            Return rowFieldRow
        End Function
        
        Public Function FindByid(ByVal id As Integer) As FieldRow
            Return CType(Me.Rows.Find(New Object() {id}),FieldRow)
        End Function
        
        Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Rows.GetEnumerator
        End Function
        
        Public Overrides Function Clone() As DataTable
            Dim cln As FieldDataTable = CType(MyBase.Clone,FieldDataTable)
            cln.InitVars
            Return cln
        End Function
        
        Protected Overrides Function CreateInstance() As DataTable
            Return New FieldDataTable
        End Function
        
        Friend Sub InitVars()
            Me.columnid = Me.Columns("id")
            Me.columnName = Me.Columns("Name")
            Me.columnDescription = Me.Columns("Description")
        End Sub
        
        Private Sub InitClass()
            Me.columnid = New DataColumn("id", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnid)
            Me.columnName = New DataColumn("Name", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnName)
            Me.columnDescription = New DataColumn("Description", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnDescription)
            Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.columnid}, true))
            Me.columnid.AutoIncrement = true
            Me.columnid.AutoIncrementSeed = -1
            Me.columnid.AutoIncrementStep = -1
            Me.columnid.AllowDBNull = false
            Me.columnid.Unique = true
        End Sub
        
        Public Function NewFieldRow() As FieldRow
            Return CType(Me.NewRow,FieldRow)
        End Function
        
        Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
            Return New FieldRow(builder)
        End Function
        
        Protected Overrides Function GetRowType() As System.Type
            Return GetType(FieldRow)
        End Function
        
        Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanged(e)
            If (Not (Me.FieldRowChangedEvent) Is Nothing) Then
                RaiseEvent FieldRowChanged(Me, New FieldRowChangeEvent(CType(e.Row,FieldRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanging(e)
            If (Not (Me.FieldRowChangingEvent) Is Nothing) Then
                RaiseEvent FieldRowChanging(Me, New FieldRowChangeEvent(CType(e.Row,FieldRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleted(e)
            If (Not (Me.FieldRowDeletedEvent) Is Nothing) Then
                RaiseEvent FieldRowDeleted(Me, New FieldRowChangeEvent(CType(e.Row,FieldRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleting(e)
            If (Not (Me.FieldRowDeletingEvent) Is Nothing) Then
                RaiseEvent FieldRowDeleting(Me, New FieldRowChangeEvent(CType(e.Row,FieldRow), e.Action))
            End If
        End Sub
        
        Public Sub RemoveFieldRow(ByVal row As FieldRow)
            Me.Rows.Remove(row)
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class FieldRow
        Inherits DataRow
        
        Private tableField As FieldDataTable
        
        Friend Sub New(ByVal rb As DataRowBuilder)
            MyBase.New(rb)
            Me.tableField = CType(Me.Table,FieldDataTable)
        End Sub
        
        Public Property id As Integer
            Get
                Return CType(Me(Me.tableField.idColumn),Integer)
            End Get
            Set
                Me(Me.tableField.idColumn) = value
            End Set
        End Property
        
        Public Property Name As String
            Get
                Try 
                    Return CType(Me(Me.tableField.NameColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableField.NameColumn) = value
            End Set
        End Property
        
        Public Property Description As String
            Get
                Try 
                    Return CType(Me(Me.tableField.DescriptionColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableField.DescriptionColumn) = value
            End Set
        End Property
        
        Public Function IsNameNull() As Boolean
            Return Me.IsNull(Me.tableField.NameColumn)
        End Function
        
        Public Sub SetNameNull()
            Me(Me.tableField.NameColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsDescriptionNull() As Boolean
            Return Me.IsNull(Me.tableField.DescriptionColumn)
        End Function
        
        Public Sub SetDescriptionNull()
            Me(Me.tableField.DescriptionColumn) = System.Convert.DBNull
        End Sub
        
        Public Function GetContributorsRows() As ContributorsRow()
            Return CType(Me.GetChildRows(Me.Table.ChildRelations("Field_Contributors")),ContributorsRow())
        End Function
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class FieldRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As FieldRow
        
        Private eventAction As DataRowAction
        
        Public Sub New(ByVal row As FieldRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As FieldRow
            Get
                Return Me.eventRow
            End Get
        End Property
        
        Public ReadOnly Property Action As DataRowAction
            Get
                Return Me.eventAction
            End Get
        End Property
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class ContributorsDataTable
        Inherits DataTable
        Implements System.Collections.IEnumerable
        
        Private columnid As DataColumn
        
        Private columnField As DataColumn
        
        Private columnName2 As DataColumn
        
        Private columnPicture As DataColumn
        
        Private columnBorn As DataColumn
        
        Private columnDied As DataColumn
        
        Private columnColourCode As DataColumn
        
        Friend Sub New()
            MyBase.New("Contributors")
            Me.InitClass
        End Sub
        
        Friend Sub New(ByVal table As DataTable)
            MyBase.New(table.TableName)
            If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
                Me.CaseSensitive = table.CaseSensitive
            End If
            If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
                Me.Locale = table.Locale
            End If
            If (table.Namespace <> table.DataSet.Namespace) Then
                Me.Namespace = table.Namespace
            End If
            Me.Prefix = table.Prefix
            Me.MinimumCapacity = table.MinimumCapacity
            Me.DisplayExpression = table.DisplayExpression
        End Sub
        
        <System.ComponentModel.Browsable(false)>  _
        Public ReadOnly Property Count As Integer
            Get
                Return Me.Rows.Count
            End Get
        End Property
        
        Friend ReadOnly Property idColumn As DataColumn
            Get
                Return Me.columnid
            End Get
        End Property
        
        Friend ReadOnly Property FieldColumn As DataColumn
            Get
                Return Me.columnField
            End Get
        End Property
        
        Friend ReadOnly Property Name2Column As DataColumn
            Get
                Return Me.columnName2
            End Get
        End Property
        
        Friend ReadOnly Property PictureColumn As DataColumn
            Get
                Return Me.columnPicture
            End Get
        End Property
        
        Friend ReadOnly Property BornColumn As DataColumn
            Get
                Return Me.columnBorn
            End Get
        End Property
        
        Friend ReadOnly Property DiedColumn As DataColumn
            Get
                Return Me.columnDied
            End Get
        End Property
        
        Friend ReadOnly Property ColourCodeColumn As DataColumn
            Get
                Return Me.columnColourCode
            End Get
        End Property
        
        Public Default ReadOnly Property Item(ByVal index As Integer) As ContributorsRow
            Get
                Return CType(Me.Rows(index),ContributorsRow)
            End Get
        End Property
        
        Public Event ContributorsRowChanged As ContributorsRowChangeEventHandler
        
        Public Event ContributorsRowChanging As ContributorsRowChangeEventHandler
        
        Public Event ContributorsRowDeleted As ContributorsRowChangeEventHandler
        
        Public Event ContributorsRowDeleting As ContributorsRowChangeEventHandler
        
        Public Overloads Sub AddContributorsRow(ByVal row As ContributorsRow)
            Me.Rows.Add(row)
        End Sub
        
        Public Overloads Function AddContributorsRow(ByVal parentFieldRowByField_Contributors As FieldRow, ByVal Name2 As String, ByVal Picture() As Byte, ByVal Born As Date, ByVal Died As Date, ByVal ColourCode As String) As ContributorsRow
            Dim rowContributorsRow As ContributorsRow = CType(Me.NewRow,ContributorsRow)
            rowContributorsRow.ItemArray = New Object() {Nothing, parentFieldRowByField_Contributors(0), Name2, Picture, Born, Died, ColourCode}
            Me.Rows.Add(rowContributorsRow)
            Return rowContributorsRow
        End Function
        
        Public Function FindByid(ByVal id As Integer) As ContributorsRow
            Return CType(Me.Rows.Find(New Object() {id}),ContributorsRow)
        End Function
        
        Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Rows.GetEnumerator
        End Function
        
        Public Overrides Function Clone() As DataTable
            Dim cln As ContributorsDataTable = CType(MyBase.Clone,ContributorsDataTable)
            cln.InitVars
            Return cln
        End Function
        
        Protected Overrides Function CreateInstance() As DataTable
            Return New ContributorsDataTable
        End Function
        
        Friend Sub InitVars()
            Me.columnid = Me.Columns("id")
            Me.columnField = Me.Columns("Field")
            Me.columnName2 = Me.Columns("Name2")
            Me.columnPicture = Me.Columns("Picture")
            Me.columnBorn = Me.Columns("Born")
            Me.columnDied = Me.Columns("Died")
            Me.columnColourCode = Me.Columns("ColourCode")
        End Sub
        
        Private Sub InitClass()
            Me.columnid = New DataColumn("id", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnid)
            Me.columnField = New DataColumn("Field", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnField)
            Me.columnName2 = New DataColumn("Name2", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnName2)
            Me.columnPicture = New DataColumn("Picture", GetType(System.Byte()), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnPicture)
            Me.columnBorn = New DataColumn("Born", GetType(System.DateTime), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnBorn)
            Me.columnDied = New DataColumn("Died", GetType(System.DateTime), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnDied)
            Me.columnColourCode = New DataColumn("ColourCode", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnColourCode)
            Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.columnid}, true))
            Me.columnid.AutoIncrement = true
            Me.columnid.AutoIncrementSeed = -1
            Me.columnid.AutoIncrementStep = -1
            Me.columnid.AllowDBNull = false
            Me.columnid.Unique = true
        End Sub
        
        Public Function NewContributorsRow() As ContributorsRow
            Return CType(Me.NewRow,ContributorsRow)
        End Function
        
        Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
            Return New ContributorsRow(builder)
        End Function
        
        Protected Overrides Function GetRowType() As System.Type
            Return GetType(ContributorsRow)
        End Function
        
        Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanged(e)
            If (Not (Me.ContributorsRowChangedEvent) Is Nothing) Then
                RaiseEvent ContributorsRowChanged(Me, New ContributorsRowChangeEvent(CType(e.Row,ContributorsRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanging(e)
            If (Not (Me.ContributorsRowChangingEvent) Is Nothing) Then
                RaiseEvent ContributorsRowChanging(Me, New ContributorsRowChangeEvent(CType(e.Row,ContributorsRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleted(e)
            If (Not (Me.ContributorsRowDeletedEvent) Is Nothing) Then
                RaiseEvent ContributorsRowDeleted(Me, New ContributorsRowChangeEvent(CType(e.Row,ContributorsRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleting(e)
            If (Not (Me.ContributorsRowDeletingEvent) Is Nothing) Then
                RaiseEvent ContributorsRowDeleting(Me, New ContributorsRowChangeEvent(CType(e.Row,ContributorsRow), e.Action))
            End If
        End Sub
        
        Public Sub RemoveContributorsRow(ByVal row As ContributorsRow)
            Me.Rows.Remove(row)
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class ContributorsRow
        Inherits DataRow
        
        Private tableContributors As ContributorsDataTable
        
        Friend Sub New(ByVal rb As DataRowBuilder)
            MyBase.New(rb)
            Me.tableContributors = CType(Me.Table,ContributorsDataTable)
        End Sub
        
        Public Property id As Integer
            Get
                Return CType(Me(Me.tableContributors.idColumn),Integer)
            End Get
            Set
                Me(Me.tableContributors.idColumn) = value
            End Set
        End Property
        
        Public Property Field As Integer
            Get
                Try 
                    Return CType(Me(Me.tableContributors.FieldColumn),Integer)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableContributors.FieldColumn) = value
            End Set
        End Property
        
        Public Property Name2 As String
            Get
                Try 
                    Return CType(Me(Me.tableContributors.Name2Column),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableContributors.Name2Column) = value
            End Set
        End Property
        
        Public Property Picture As Byte()
            Get
                Try 
                    Return CType(Me(Me.tableContributors.PictureColumn),Byte())
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableContributors.PictureColumn) = value
            End Set
        End Property
        
        Public Property Born As Date
            Get
                Try 
                    Return CType(Me(Me.tableContributors.BornColumn),Date)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableContributors.BornColumn) = value
            End Set
        End Property
        
        Public Property Died As Date
            Get
                Try 
                    Return CType(Me(Me.tableContributors.DiedColumn),Date)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableContributors.DiedColumn) = value
            End Set
        End Property
        
        Public Property ColourCode As String
            Get
                Try 
                    Return CType(Me(Me.tableContributors.ColourCodeColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableContributors.ColourCodeColumn) = value
            End Set
        End Property
        
        Public Property FieldRow As FieldRow
            Get
                Return CType(Me.GetParentRow(Me.Table.ParentRelations("Field_Contributors")),FieldRow)
            End Get
            Set
                Me.SetParentRow(value, Me.Table.ParentRelations("Field_Contributors"))
            End Set
        End Property
        
        Public Function IsFieldNull() As Boolean
            Return Me.IsNull(Me.tableContributors.FieldColumn)
        End Function
        
        Public Sub SetFieldNull()
            Me(Me.tableContributors.FieldColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsName2Null() As Boolean
            Return Me.IsNull(Me.tableContributors.Name2Column)
        End Function
        
        Public Sub SetName2Null()
            Me(Me.tableContributors.Name2Column) = System.Convert.DBNull
        End Sub
        
        Public Function IsPictureNull() As Boolean
            Return Me.IsNull(Me.tableContributors.PictureColumn)
        End Function
        
        Public Sub SetPictureNull()
            Me(Me.tableContributors.PictureColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsBornNull() As Boolean
            Return Me.IsNull(Me.tableContributors.BornColumn)
        End Function
        
        Public Sub SetBornNull()
            Me(Me.tableContributors.BornColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsDiedNull() As Boolean
            Return Me.IsNull(Me.tableContributors.DiedColumn)
        End Function
        
        Public Sub SetDiedNull()
            Me(Me.tableContributors.DiedColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsColourCodeNull() As Boolean
            Return Me.IsNull(Me.tableContributors.ColourCodeColumn)
        End Function
        
        Public Sub SetColourCodeNull()
            Me(Me.tableContributors.ColourCodeColumn) = System.Convert.DBNull
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class ContributorsRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As ContributorsRow
        
        Private eventAction As DataRowAction
        
        Public Sub New(ByVal row As ContributorsRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As ContributorsRow
            Get
                Return Me.eventRow
            End Get
        End Property
        
        Public ReadOnly Property Action As DataRowAction
            Get
                Return Me.eventAction
            End Get
        End Property
    End Class
End Class

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Ireland Ireland
Declan Brennan is Chief Architect for Sekos Technology (www.sekos.com). Over the years he has worked in a huge range of technologies and environments and still gets a great thrill from the magic of computers.

Comments and Discussions