Hi,
I have a custom control (Benutzersteuerelement) which creates a textbox dynamicly:
Set txtEdit = UserControl.controls.Add("VB.TextBox", "txtEdit")
In my project I can place a EditCtlsLibUCtl.TextBox on a form, but I cannot create it dynamically like this:
Private WithEvents txtEdit As EditCtlsLibUCtl.TextBox
...
Set txtEdit = UserControl.controls.Add("EditCtlsLibUCtl.TextBox", "txtEdit")
It says: runtime error 739 The ProgId must be used. The ProgID of this control is EditCtlsLibUCtl.TextBox.1
But
Set txtEdit = UserControl.controls.Add("EditCtlsLibUCtl.TextBox.1", "txtEdit")
doesn't work either...
What can I do?
Peter
Create Textbox dynamicly
Re: Create Textbox dynamicly
Hi,
The following code works for me, if I go to the project settings and deactivate the option "Remove information about inactive ActiveX controls."
Regards
TiKu
The following code works for me, if I go to the project settings and deactivate the option "Remove information about inactive ActiveX controls."
Code: Select all
Option Explicit
Private WithEvents txtEdit As EditCtlsLibUCtl.TextBox
Private Sub Form_Click()
Set txtEdit = Me.Controls.Add("EditCtlsU.TextBox", "txtEdit")
txtEdit.Move 120, 120, 1500, 330
txtEdit.Visible = True
End Sub
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
-
- Lieutenant
- Posts: 23
- Joined: 15 Aug 2010, 08:42
Re: Create Textbox dynamicly
You are right. There is no warning now.
But now I can't no longer put this user control on a form. Than comes the warning again.
But hey, forget it! doesn't matter. It is only one text box that get added dynamically. So I will make a workaround. I'll put the textbox on the user control directly and show/hide it. That should work.
But now I can't no longer put this user control on a form. Than comes the warning again.
But hey, forget it! doesn't matter. It is only one text box that get added dynamically. So I will make a workaround. I'll put the textbox on the user control directly and show/hide it. That should work.
Re: Create Textbox dynamicly
It still works for me if I put the code into a UserControl and change Form_Click to UserControl_Click and Me.Controls to UserControl.Controls. I can place the control onto a Form and when I click the control, a Textbox is added.
Is your UserControl in a separate project? I did put it into the same project as the Form. Did you, by any chance, forget to deactivate the option that I mentioned in the UserControl project?
Is your UserControl in a separate project? I did put it into the same project as the Form. Did you, by any chance, forget to deactivate the option that I mentioned in the UserControl project?
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!