
| Visual Basic (Declaration) | |
|---|---|
Public NotInheritable Class Selection | |
| C# | |
|---|---|
public sealed class Selection | |
The PivotView control allows a user to select header cells or data points. This class allows to investigate the corresponding dimensions members. Only one of the Dimensions and DataPoints properties can be nonempty at the same time. If a user selects header cells, then Dimensions will contain information on the selection. If a user selects data points then DataPoints will contain information on the selection.
The following code example demonstrates how to use the Selection class. To run this example, you need to create two forms named Form1 and SelectionViewForm. Then paste the following code into them:
| C# | Copy Code |
|---|---|
public partial class SelectionViewForm : Form { private readonly ListView listView; public SelectionViewForm() { InitializeComponent(); listView = new ListView(); listView.Dock = DockStyle.Fill; listView.View = View.Details; Controls.Add(listView); } public void FillList(PivotView pivotView) { listView.Items.Clear(); listView.Columns.Clear(); TupleSet tupleSet = pivotView.Selection.Dimensions.Count > 0 ? pivotView.Selection.Dimensions[0] : pivotView.Selection.DataPoints; if(tupleSet.IsEmpty) return; foreach (Hierarchy hierarchy in tupleSet.Definition) { listView.Columns.Add(hierarchy.Caption); } foreach (Tuple tuple in tupleSet) { string[] captions = new string[tuple.Count]; for (int i = 0; i < tuple.Count; i++) { captions[i] = tuple[i].Caption; } listView.Items.Add(new ListViewItem(captions)); } } } public partial class Form1 : Form { private readonly MdxDataSource mdxDataSource; private readonly PivotView pivotView; private readonly SelectionViewForm _selectionViewForm; public Form1() { InitializeComponent(); mdxDataSource = new MdxDataSource(); mdxDataSource.ConnectionString = "Provider=SQLOLEDB.1;Data Source=localhost;Initial Catalog=Adventure Works DW"; mdxDataSource.Connect(); pivotView = new PivotView(); pivotView.DataSource = mdxDataSource; pivotView.Dock = DockStyle.Fill; Controls.Add(pivotView); pivotView.SelectionChanged += pivotView_SelectionChanged; _selectionViewForm = new SelectionViewForm(); } void pivotView_SelectionChanged(object sender, EventArgs e) { if (!_selectionViewForm.Visible) { _selectionViewForm.Show(this); } _selectionViewForm.FillList(pivotView); } } | |
System.Object
GrapeCity.ActiveAnalysis.Data.Selection
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2