Untested - OHM
Public Class JoinTextBoxColumn
Inherits DataGridTextBoxColumn
' Store information necessary to retrieve fields.
Private relationName As String
Private parentField As DataColumn
Public Sub New(RelationName As String, ParentField As DataColumn)
relationName = RelationName
parentField = ParentField
MyBase.ReadOnly = True
End Sub 'New
Protected Overrides Function GetColumnValueAtRow(cm As CurrencyManager,
RowNum As Integer) As Object
' Get the current DataRow from the CurrencyManager.
' Use the GetParentRow and the DataRelation name to get
' the parent row.
' Return the field value from the parent row.
Try
Dim dr As DataRow = CType(cm.List, DataView)(RowNum).Row
Dim drParent As DataRow = dr.GetParentRow(relationName)
Return drParent(parentField).ToString()
Catch
End Try
End Function 'GetColumnValueAtRow
' Necessary when adding rows.
Protected Overrides Function Commit(cm As CurrencyManager, RowNum As
Integer) As Boolean
Return False ' Dummy implementation because it is read-only
End Function 'Commit
Public Shadows ReadOnly Property [ReadOnly]() As Boolean ' Hide base
member ReadOnly.
Get
Return True
End Get
End Property
End Class 'JoinTextBoxColumn