Qlik Community

QlikView Integration

Discussion Board for collaboration on QlikView Integration.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

set selection by C# OCX

Hey,

I want to set a certain selection by C# code in OCX. First I open some QVW Application and delete the current selection:

Application app = new Application();

Doc doc = app.OpenDoc(@"...\Example.qvw");

//clear current selection

doc.ClearAll();

Now, I want maybe set the selection on the dimension time. For instance the value day and month.

How can I achieve this.

Thank you for some tips.

1 Solution

Accepted Solutions
Not applicable

Re: set selection by C# OCX

Hi,

this is the solution:

  Field fieldInvestmentRegion = doc.GetField("Investment Region");

IArrayOfFieldValues investFields = fieldInvestmentRegion.GetNoValues();

  investFields.Add();

  investFields[0].Text =  "Italy";

  investFields.Add();

  investFields[1].Text =  "Japan";

  fieldInvestmentRegion.SelectValues(investFields);

2 Replies
Not applicable

Re: set selection by C# OCX

Hello,

                IList<QlikViewVariable> list = new List<QlikViewVariable>();

                for (int i = 0; i < qvReport.GetVariableDescriptions().Count; i++)

                {

                    IVariableDescription v = qvReport.GetVariableDescriptions();

                    //Console.WriteLine("Variable name : "+v.Name);

                    if (!(v.Name.Contains("filter")))

                    {

                        //Console.WriteLine(qvReport.GetVariable(v.Name).GetRawContent());

                        list.Add(new QlikViewVariable(v.Name, qvReport.GetVariable(v.Name).GetRawContent()));

                    }

                }

This might return you the variables from your report.

Now if you want to set any selection:

            foreach (KeyValuePair<string, object> p in <your selections>)

            {

                Variable v = qvReport.Variables(p.Key);

                if (v != null)

                {

                        //Console.WriteLine("Before modification content : " + v.GetContent().String);

                        v.SetContent(p.Value.ToString(), true);

                        //Console.WriteLine("Current content : " + v.GetContent().String);

                        variables = null;

                }

            }

            qvReport.Reload(0);

But, I'll ask a question to avoid the qvReport.Reload(0), because if you want to select several months and generate a report, you have to reload the whole report again which might take hours and hours ...

Not applicable

Re: set selection by C# OCX

Hi,

this is the solution:

  Field fieldInvestmentRegion = doc.GetField("Investment Region");

IArrayOfFieldValues investFields = fieldInvestmentRegion.GetNoValues();

  investFields.Add();

  investFields[0].Text =  "Italy";

  investFields.Add();

  investFields[1].Text =  "Japan";

  fieldInvestmentRegion.SelectValues(investFields);

Community Browser