C
crjunk
Is is possible to dynamically create and add textboxes to a form when
a button is clicked?
I've written and tried to execute the following code:
Dim ctrl As Control
Dim ctlNameCB As ComboBox
Dim FieldName As String
Private Sub brnOverlay_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles brnOverlay.Click
For Each ctrl In Me.Controls
If TypeOf (ctrl) Is ComboBox Then
ctlNameCB = ctrl
FieldName = ctrl.Name
Dim MyTextBox = New TextBox
MyTextBox.text = ctlNameCB.SelectedText
MyTextBox.id = "txt" & ctlNameCB.Name
MyTextBox.location.x = ctlNameCB.Location.X
MyTextBox.location.y = ctlNameCB.Location.Y
MyTextBox.Size.Width = (ctlNameCB.Size.Width - 10)
MyTextBox.Size.Height = ctlNameCB.Size.Height
End If
Next
End Sub
End Class
But I'm receiving the following error when executing it: "Late-bound
assignment to a field of value type 'Point' is not valid when 'Point'
is the result of a late-bound expression"
The error is occurring when the "MyTextBox.location.x =
ctlNameCB.Locaiton.X " is executed.
I'm coming at this from an ASP.NET background so there might be
something obvious that I'm overlooking.
Thanks,
crjunk
a button is clicked?
I've written and tried to execute the following code:
Dim ctrl As Control
Dim ctlNameCB As ComboBox
Dim FieldName As String
Private Sub brnOverlay_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles brnOverlay.Click
For Each ctrl In Me.Controls
If TypeOf (ctrl) Is ComboBox Then
ctlNameCB = ctrl
FieldName = ctrl.Name
Dim MyTextBox = New TextBox
MyTextBox.text = ctlNameCB.SelectedText
MyTextBox.id = "txt" & ctlNameCB.Name
MyTextBox.location.x = ctlNameCB.Location.X
MyTextBox.location.y = ctlNameCB.Location.Y
MyTextBox.Size.Width = (ctlNameCB.Size.Width - 10)
MyTextBox.Size.Height = ctlNameCB.Size.Height
End If
Next
End Sub
End Class
But I'm receiving the following error when executing it: "Late-bound
assignment to a field of value type 'Point' is not valid when 'Point'
is the result of a late-bound expression"
The error is occurring when the "MyTextBox.location.x =
ctlNameCB.Locaiton.X " is executed.
I'm coming at this from an ASP.NET background so there might be
something obvious that I'm overlooking.
Thanks,
crjunk