Microsoft KB Archive/820642

= Default option for the DataSource property of a PivotTable is not displayed =

Article ID: 820642

Article Last Modified on 1/12/2007

-

APPLIES TO


 * Microsoft Visual Basic 2005
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual C# 2005 Express Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-





SYMPTOMS
You have a Microsoft Windows Form that contains a PivotTable ActiveX control. When you try to set the DataSource property of the control in Windows Forms Designer, you notice that the default option is not displayed in the drop-down list of the DataSource property.

Note In Microsoft Visual Basic 6.0, the default options are displayed in the drop-down list of the DataSource property.



CAUSE
This behavior occurs because the PivotTable ActiveX control does not support early binding of data source in Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET. Therefore, the default option is not displayed in the drop-down list of the DataSource property in Windows Forms Designer.



WORKAROUND
To work around this behavior, set the DataSource property of the PivotTable control at runtime. To do this, follow these steps:   Add the following code to the Load event of the Form1 form.

Microsoft Visual Basic 2005 or Microsoft Visual Basic .NET code 'Create an instance of the PivotTable control. Dim AxPivotTable2 As New AxOWC.AxPivotTable 'Set the datasource property of the control to the default option. AxPivotTable2.DataSource = AxPivotTable2.GetOcx 'Add the control to the form. Me.Controls.Add(AxPivotTable2) Microsoft Visual C# 2005 or Microsoft Visual C# .NET code //Create an instance of the PivotTable control. AxOWC.AxPivotTable AxPivotTable2 =new AxOWC.AxPivotTable; //Set the datasource property of the control to the default option. AxPivotTable2.DataSource = (msdatasrc.DataSource)AxPivotTable2.GetOcx; //Add the control to the form. this.Controls.Add(AxPivotTable2);  On the Debug menu, click Start.



STATUS
This behavior is by design.



Steps to reproduce the behavior

 * 1) In Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET, start a new Windows Application by using Visual Basic 2005, Visual Basic .NET, Visual C# 2005, or Visual C# .NET. By default, Form1 is created.
 * 2) On the Tools menu, click Customize Toolbox.

Note In Microsoft Visual Studio .NET 2003, click Add/Remove Toolbox Items on the Tools menu. In Visual Studio 2005, click Choose Toolbox Items on the Tools menu..
 * 1) On the COM Components tab, select Microsoft Office PivotTable 9.0, Microsoft Office PivotTable 10.0, or Microsoft Office PivotTable 11.0, and then click OK.
 * 2) Add a PivotTable control to the Form1 form.
 * 3) Right-click AxPivotTable1, click Properties, and then click the DataSource property.

In the DataSource property drop-down list, notice that the default option AxPivotTable1 is not available.

Note In Microsoft Visual Basic 6.0, notice the default option (for example PivotTable1) in the drop-down list of the DataSource property.

