Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding Controls Ar Runtime
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00687610
Message ID:
00688664
Vues:
24
Thats what I'm trying to do. I have a control that adds
additional controls to itself at runtime:

I created a user control called ctlButton. It's nothing
but a UserControl with a command button on it. It's code
is simple:
Public Event Clicked()

Public Property Get Caption() As String
  Caption = cmdButton.Caption
End Property

Public Property Let Caption(ByVal sNewCaption As String)
  cmdButton.Caption = sNewCaption
End Property

Private Sub cmdButton_Click()
  RaiseEvent Clicked
End Sub
Next, I created a second UserControl called Base. It will contain all
the other controls added at runtime. It's code is:
Option Explicit
Dim WithEvents ctlButton As VBControlExtender
Public MyControls As New Collection

Private Sub UserControl_Initialize()
   
  Set ctlButton = Controls.Add("TestProj.ctlButton", "ctlButton")
   
  With ctlButton
      
    .Visible = True
    .Top = 10
    .Left = 10
      
  End With

  MyControls.Add ctlButton

End Sub

Private Sub ctlButton_ObjectEvent(Info As EventInfo)
   
   Select Case Info.Name
     
     Case "Clicked"
        MsgBox "Button was clicked"
   
    Case Else
   
   End Select
Everything works fine except this. The MyControls.Add adds
the newly added ctlButton to the collection, but when I drop Base
onto a form and run it, the do Base1.MyControls(1)., I don't
see anything. I thought the public property Caption was supposed
to be available?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform