Qlik Community

QlikView Integration

Discussion Board for collaboration on QlikView Integration.

QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Contributor II

Get objects used in a container using OCX in C#?


I'm trying to get the list of objects used in a container object using C#.

But there is no GetProperties() function for SheetObjects in OCX library.

i found the below code to set the container objects using vb Macro. it has a method to get the contained objects.

Is there any method to achieve this in C#?

Set ContainerObj = ActiveDocument.Sheets("Main").CreateContainer

set ContProp=ContainerObj.GetProperties






ContProp.ContainedObjects.Item(0).Id = "Document\CH03"

ContProp.ContainedObjects.Item(0).Text.v = "Bar"


ContProp.ContainedObjects.Item(1).Id = "Document\CH01"

ContProp.ContainedObjects.Item(1).Text.v = "Mekko"

ContainerObj.SetProperties ContProp

Thanks in Advance.

Tags (3)
5 Replies

Re: Get objects used in a container using OCX in C#?


Here is a routine I wrote for one of my customer to create a container object and populate it. It is a VB.Net snippet and you should be able to use the same object reference to get the object id’s of the objects in the container then use those to get the object’s properties.



Private Sub addObjectToContainer()

Dim ListboxObj As QlikView.ListBox

Dim LBProp As QlikView.IListBoxProperties

Dim LBID As String

Dim Fields(6) As String

Dim ContainerObj As QlikView.Container

Dim ContProp As QlikView.IContainerProperties

Dim ContFrame As QlikView.IFrame

Dim i As Integer

'[ init field list of Data model fields we want in list boxes

Fields(0) = "Customer"

Fields(1) = "Salesman"

Fields(2) = "Distributor ID"

Fields(3) = "Product ID"

Fields(4) = "Country"

Fields(5) = "Year"

'[ Initialize the container

ContainerObj = AxQlikOCX1.ActiveDocument.Sheets("Main").CreateContainer

ContProp = ContainerObj.GetProperties

ContProp.Frame.Name.v = "Selections"

ContProp.SingleObjectMode = 1

ContProp.SingleObjectStyle = 1

ContProp.ShowObjectTypeIcons = True

'[ actiate the sheet we want the container on (sheet name is case sensitive)


'[ create the listbox, add it to the container, then close the listbox out (delete it)

For i = 0 To 5

'[ create the list box and set properties

ListboxObj = AxQlikOCX1.ActiveDocument.Sheets("Main").CreateListBox

LBID = ListboxObj.GetObjectId

LBProp = ListboxObj.GetProperties

LBProp.Def.Name = Fields(i)

LBProp.Def.Type = 1 '[ field


'[ add the listbox to the container


ContProp.ContainedObjects.Item(i).Def.ObjectId = LBID

ContProp.ContainedObjects.Item(i).Text.v = Fields(i)

'[ remove the newly created list box from the sheet but leave the copy in the container object



'[ set the container properties


'[ Set container position and size

Dim rect As QlikView.IRect

rect = ContainerObj.GetRect

rect.Left = 2

rect.Top = 170

rect.Width = 274

rect.Height = 300


End Sub

Not applicable

Re: Get objects used in a container using OCX in C#?

Hi Jeff,

In slight variations of the above code, I'm trying to loop through the objects in a container and export them to Excel, but QV does not seem to like that.  Any suggestions on looping through the objects in a container and making this work?  I get an invalid FOR loop variable error.. Thanks in advance!!

For i = 1 To ActiveDocument.NoOfSheets -2

     Set MySheet = ActiveDocument.GetSheet(i)



      For X =lbound(contCharts) to ubound(contCharts) 

      Set obj = ActiveDocument.GetSheetObject(contCharts(X).GetObjectId)

IF obj.GetObjectType = 36 then

      Set ContProp=obj.GetProperties

     Msgbox ContProp.ContainedObjects.Count   'it displays the count of objects correctly but it errors out in the next line below..

    For i = 0 to ((ContProp.ContainedObjects.Count) -1)

     ' export only the object types 10 to 16

     IF ContProp.ContainedObjects.Items(i).GetObjectType >= 10 AND ContProp.ContainedObjects.Items(i).GetObjectType =< 16 Then

          ContProp.ContainedObjects.Items(i).CopyValuesToClipboard true

          Msgbox ContProp.ContainedObjects.Items(i).GetCaption

'      End if


End if


Not applicable

Re: Get objects used in a container using OCX in C#?

Where do I find the properties and methods of ContainedObjects member? I cant find any in the user manual, nor much information in the API guide.  Get the error that -

Object doesn't support this property or method: 'ContProp.ContainedObjects.Items'

Contributor II

Re: Re: Get objects used in a container using OCX in C#?

Hi Jeff,

Thanks for the reply...

i used the below code to get the object IDs of the contained object.

          if (Sheets.SheetObjects(i.ToString()).GetObjectType() == 36)


                    var Obj = (QlikView.Container)Doc.GetSheetObject(objectid);

                    var containerObjs = Obj.GetProperties().ContainedObjects;

                    for (int j = 0; j < containerObjs.Count; j++)


                        var ContainedObjId=containerObjs.Id_OBSOLETE;

                        var Def = containerObjs.Text;

                        string[] row = { ContainedObjId.Replace("Document\\", ""), Def.v, "Container " + objectid };

                        var listViewItem = new ListViewItem(row);





Prabhu Appu

Contributor II

Re: Re: Get objects used in a container using OCX in C#?

Hi Nithya,

When copy the values to clipboard of contained objects, you need to activate the object.

but i couldn't see any function to activate the container object. So what i did is, i have created a copy of the object in a new sheet and then copied the values to clipboard (and don't forget to delete the newly created object before saving the application). Please find the below code for creating a copy of that object,

if (objecttype.Contains("Container"))


                    QlikView.SheetObject QlikObject = (QlikView.SheetObject)Obj;

                    QlikView.Document QlikDoc = (QlikView.Document)Doc;

                    createobject(QlikDoc, QlikObject);




QlikView.Graph ObjectType14 = (QlikView.Graph)obj;

                    ObjectType14.WriteXmlPropertiesFile("Filename" + obj.GetObjectId().Replace("\\","") + ".xml");


before copying the value or image to clipboard you need to activate that sheet and object,

if (objecttype.Contains("Container"))


                    var ContainerObj = Doc.GetSheetObject(listView1.SelectedItems[0].SubItems[2].Text.Replace("Container\\",""));








                    var docalias = (QlikView.Document)Doc;




Prabhu Appu

Community Browser