N
Nathan Carroll
I'd like to use the below inherited control that is incorporated into a
CollectionBase to Create controls on a usercontrol.
My question is it possible to copy/clone from the collection of the user
control. When i try to add the control from the collection I am only able
to add one control. See Below BuiltIt. My Solution is to loop through the
collection and set the properties of a new inherited control. This seems
the long way am I missing something?
<System.ComponentModel.DesignTimeVisible(False)> _
Public Class Columns
Inherits System.Windows.Forms.TextBox
End Class
Sub BuildIt()
Dim l As Columns
Dim j As Integer
Static rowtop As Integer
For j = 0 To 2
Dim r As New Panel
With r
..Width = Me.Width
..Top = rowtop
..Height = 24
..Left = 0
rowtop += .Height
End With
Static left As Integer
left = 0
For Each l In Me.m_ColumnHeaders
' Me.Controls.Add(l)
Dim tb As New Columns
With tb
'this is fine but what about databinding
Dim s As String
s = l.DataBindings.Item(0).BindingMemberInfo.BindingField().ToString
..Left = left
left = left + .Width + 2
..Text = l.Text
Try
..DataBindings.Add("Text", Datasource, s)
Catch ex As Exception
End Try
End With
r.Controls.Add(tb)
Next
Me.Controls.Add(r)
Next
End Sub
CollectionBase to Create controls on a usercontrol.
My question is it possible to copy/clone from the collection of the user
control. When i try to add the control from the collection I am only able
to add one control. See Below BuiltIt. My Solution is to loop through the
collection and set the properties of a new inherited control. This seems
the long way am I missing something?
<System.ComponentModel.DesignTimeVisible(False)> _
Public Class Columns
Inherits System.Windows.Forms.TextBox
End Class
Sub BuildIt()
Dim l As Columns
Dim j As Integer
Static rowtop As Integer
For j = 0 To 2
Dim r As New Panel
With r
..Width = Me.Width
..Top = rowtop
..Height = 24
..Left = 0
rowtop += .Height
End With
Static left As Integer
left = 0
For Each l In Me.m_ColumnHeaders
' Me.Controls.Add(l)
Dim tb As New Columns
With tb
'this is fine but what about databinding
Dim s As String
s = l.DataBindings.Item(0).BindingMemberInfo.BindingField().ToString
..Left = left
left = left + .Width + 2
..Text = l.Text
Try
..DataBindings.Add("Text", Datasource, s)
Catch ex As Exception
End Try
End With
r.Controls.Add(tb)
Next
Me.Controls.Add(r)
Next
End Sub