This is a migrated thread and some comments may be shown as answers.

Adding COM objects to a radDockPanel

1 Answer 121 Views
Dock
This is a migrated thread and some comments may be shown as answers.
JulioR
Top achievements
Rank 1
JulioR asked on 10 Aug 2007, 11:06 AM
Hi,

I'm trying to add a MapPoint ocx component to a radDockPanel at runtime.

Me.pnMap = New Telerik.WinControls.Docking.DocumentPane
Dim oMap As New MapPoint.MappointControl
Me.pnMap.Controls.Add(oMap)

The following error occurs:

Unable to cast COM object of type 'MapPoint.MappointControlClass' to class type 'System.Windows.Forms.Control'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

If I embed the control from the toolbox at design time everything works fine, so could you please help me with this?

Regards,

1 Answer, 1 is accepted

Sort by
0
JulioR
Top achievements
Rank 1
answered on 10 Aug 2007, 02:06 PM
I have already found the solution:

CType(AxMappointControl1, System.ComponentModel.ISupportInitialize).BeginInit()

Me.pnMap.Controls.Add(AxMappointControl1)

AxMappointControl1.dock = DockStyle.Fill

 AxMappointControl1.Enabled = True

AxMappointControl1.Location = New System.Drawing.Point(71, 212)

AxMappointControl1.Name = "AxMappointControl1"

AxMappointControl1.Size = New System.Drawing.Size(535, 216)

AxMappointControl1.TabIndex = 1

CType(AxMappointControl1, System.ComponentModel.ISupportInitialize).EndInit()

AxMappointControl1.NewMap(GeoMapRegion.geoMapEurope)

I did it exactly in the same order than the designer.vb and it works now.
I hope this info will be useful for someone. :)

Regards,

Tags
Dock
Asked by
JulioR
Top achievements
Rank 1
Answers by
JulioR
Top achievements
Rank 1
Share this question
or