conradoplg
New member
- Joined
- Sep 12, 2007
- Messages
- 2
- Programming Experience
- 3-5
Is there a way to replace a instance of a ActiveX control in a form with a new instance of the same control?
Thanks!
Thanks!
dim withevents a as new flashobject ' flashobject is an hypothetical class
sub ManInstance()
a=nothing 'if you want to delete the instance of the heap
a=new flashobject 'here you'll have a complete new instance ready to use
'me.controls.remove(a) 'use this if you want to remove the control of the
container
dim b as new flashobject
me.controls.add(b) ' set the position and size using values of a.
end sub
Me.AxAcroPDF1 = New AxAcroPDFLib.AxAcroPDF
CType(Me.AxAcroPDF1, System.ComponentModel.ISupportInitialize).BeginInit()
[COLOR="Green"]'
'AxAcroPDF1
'[/COLOR]
Me.AxAcroPDF1.Enabled = True
Me.AxAcroPDF1.Location = New System.Drawing.Point(631, 128)
Me.AxAcroPDF1.Name = "AxAcroPDF1"
Me.AxAcroPDF1.OcxState = CType(resources.GetObject("AxAcroPDF1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxAcroPDF1.Size = New System.Drawing.Size(59, 48)
Me.AxAcroPDF1.TabIndex = 13
Me.Controls.Add(Me.AxAcroPDF1)
CType(Me.AxAcroPDF1, System.ComponentModel.ISupportInitialize).EndInit()
Sub replaceAcroAX()
Dim resources As System.ComponentModel.ComponentResourceManager = _
New System.ComponentModel.ComponentResourceManager(GetType(frmDiv))
[COLOR="Green"]'remove and dispose[/COLOR]
Me.Controls.Remove(AxAcroPDF1)
AxAcroPDF1.Dispose()
[COLOR="Green"]'create new instance, the AxAcroPDF1 variable can be reused (*)[/COLOR]
Me.AxAcroPDF1 = New AxAcroPDFLib.AxAcroPDF
[COLOR="green"]'BeginInit[/COLOR]
CType(Me.AxAcroPDF1, System.ComponentModel.ISupportInitialize).BeginInit()
[COLOR="green"]'configure it[/COLOR]
Me.AxAcroPDF1.Enabled = True
Me.AxAcroPDF1.Location = New System.Drawing.Point(631, 128)
Me.AxAcroPDF1.Name = "AxAcroPDF1"
Me.AxAcroPDF1.OcxState = CType(resources.GetObject("AxAcroPDF1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxAcroPDF1.Size = New System.Drawing.Size(59, 48)
Me.AxAcroPDF1.TabIndex = 13
[COLOR="green"]'add to form[/COLOR]
Me.Controls.Add(Me.AxAcroPDF1)
[COLOR="green"]'EndInit[/COLOR]
CType(Me.AxAcroPDF1, System.ComponentModel.ISupportInitialize).EndInit()
End Sub