Create Textbox dynamicly

The place for threads about TimoSoft EditControls.
Post Reply
Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

Create Textbox dynamicly

Post by Rucksacktraeger » 26 Feb 2016, 06:13

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

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Create Textbox dynamicly

Post by TiKu » 26 Feb 2016, 20:23

Hi,

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
Regards
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

Re: Create Textbox dynamicly

Post by Rucksacktraeger » 27 Feb 2016, 09:42

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.

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Create Textbox dynamicly

Post by TiKu » 27 Feb 2016, 11:16

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?
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

Post Reply