Adding COM objects to a radDockPanel

2 posts, 0 answers
  1. JulioR
    JulioR avatar
    26 posts
    Member since:
    Dec 2006

    Posted 10 Aug 2007 Link to this post

    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,

  2. JulioR
    JulioR avatar
    26 posts
    Member since:
    Dec 2006

    Posted 10 Aug 2007 Link to this post

    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,

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top