Strokes.Remove Method

Strokes.Remove Method

Removes a Stroke object from the Strokes collection.

Definition

Visual Basic .NET Public Sub Remove( _
ByVal stroke As Stroke _
)
C# public void Remove(
Stroke stroke
);
Managed C++ public: void Remove(
Stroke *stroke
);

Parameters

stroke Microsoft.Ink.Stroke. The Stroke object to remove.

Exceptions

ArgumentException Leave Site: The parameter is not valid.
ArgumentException Leave Site: The parameter is not valid.
COMException Leave Site:
ObjectDisposedException Leave Site: The Strokes collection is disposed.

Remarks

Stroke objects are references to data and are not the actual data itself. This method removes the Stroke object only from a snapshot of, or reference to, the data and does not remove the actual ink data. To delete the Stroke object from the actual ink data, call the Ink.DeleteStroke method.

After calling the Remove method, the Stroke objects in the collection are reordered. For example, in Microsoft® Visual Basic® .NET, after calling Strokes.Remove(Strokes.Item(0)), what was Strokes.Item(1) becomes Strokes.Item(0); what was strokes.Item(2) becomes strokes.Item(1); and so forth.

Examples

[C#]

This C# example removes Stroke objects from a Strokes collection, theLeftToRightStokes, if the first point in the Stroke is not to the left of the last point in the Stroke. The original data in the Ink object are unaffected.

//...
foreach (Stroke testStroke in theLeftToRightStrokes)
{
    Point ptStart = testStroke.GetPoint(0);
    Point ptEnd = testStroke.GetPoint(testStroke.PacketCount - 1);
    if (ptStart.X > ptEnd.X)
        theLeftToRightStrokes.Remove(testStroke);
}
                

[VB.NET]

This Visual Basic .NET example removes Stroke objects from a Strokes collection, theLeftToRightStokes, if the first point in the Stroke is not to the left of the last point in the Stroke. The original data in the Ink object are unaffected.

'...
Dim testStroke As Stroke
For Each testStroke in theLeftToRightStrokes
    Dim ptStart As Point = testStroke.GetPoint(0)
    Dim ptEnd As Point = testStroke.GetPoint(testStroke.PacketCount - 1)
    If ptStart.X > ptEnd.X Then
        TheLeftToRightStrokes.Remove(testStroke)
    End If
Next
                

See Also