BeginObject Method

Microsoft Office Web Components Visual Basic

expression.BeginObject(id)

expression    Required. An expression that returns a ChChartDraw object.

id   Required Long. Set this argument to a unique identifier that will subsequently be used to identify the object being drawn. Set to -1 to identify the ChChartDraw object that has been passed into an event procedure.

Remarks

You can combine multiple drawing elements into a single user-selectable item by placing them between calls to the BeginObject and EndObject methods.

Example

This example uses the BeforeRender event to cancel the drawing of the gridlines and the plot area of the first chart in Chartspace1. The AfterRenderEvent then replaces the plot area with an ellipse that is drawn after the chart is rendered.

Private Sub ChartSpace1_BeforeRender(chartObject, Cancel)

    Select Case TypeName(chartObject)

        Case "ChGridlines"

            ' Cancel the drawing of the gridlines.
            Cancel.Value = True

        Case "ChPlotArea"

            ' Cancel the drawing of the plot area.
            Cancel.Value = True

    End Select

End Sub

Private Sub ChartSpace1_AfterRender(drawObject, chartObject)

    Dim chConstants

    Set chConstants = ChartSpace1.Constants

    ' Check to see if the chart has been rendered.
    If TypeName(chartObject) = "ChChart" Then

        ' The next three lines of code set the interior
        ' and border properties of the ellipse.
        drawObject.Interior.SetPresetGradient _
               chConstants.chGradientHorizontal, _
               chConstants.chGradientVariantStart, _
               Int((24 - 1 + 1) * Rnd + 1)
        drawObject.Border.Weight = 1
        drawObject.Border.Color = "black"

        ' Begin the drawing object.
        drawObject.BeginObject 1

        ' Draw the ellipse.
        drawObject.DrawEllipse chartObject.PlotArea.Left, chartObject.PlotArea.Bottom, _
                               chartObject.PlotArea.Right, chartObject.PlotArea.Top

        drawObject.EndObject

  End If

End Sub