Chart.ChartGroups 方法

获取单个图表组(ChartGroup 对象)或图表中所有图表组的集合(ChartGroups 对象)。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Function ChartGroups ( _
    Index As Object _
) As Object
Object ChartGroups(
    Object Index
)

参数

返回值

类型:System.Object
单个图表组(ChartGroup 对象)或图表中所有图表组的集合(ChartGroups 对象)。返回的集合包括所有类型的组。

备注

可选参数

有关可选参数的信息,请参见Office 解决方案中的可选参数

示例

下面的代码示例创建一个柱形 Chart,然后使用 ChartGroups 方法修改柱形之间的间距。

Private Sub UseChartGroups()
    Me.Range("A1", "A5").Value2 = 22
    Me.Range("B1", "B5").Value2 = 55

    Dim Chart1 As Microsoft.Office.Tools.Excel.Chart = _
        Me.Controls.AddChart(Me.Range("D2", "H12"), "Chart1")

    Chart1.SetSourceData(Me.Range("A1", "B5"), Excel.XlRowCol.xlColumns)
    Chart1.ChartType = Excel.XlChartType.xl3DColumn

    Dim group As Excel.ChartGroup = CType(Chart1.ChartGroups(1), _
        Excel.ChartGroup)
    group.GapWidth = 400
End Sub
private void UseChartGroups()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");

    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    Excel.ChartGroup group =
        (Excel.ChartGroup)chart1.ChartGroups(1);

    group.GapWidth = 400;
}

.NET Framework 安全性

请参见

参考

Chart 接口

Microsoft.Office.Tools.Excel 命名空间