GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / RemoveRegionByName Method
The name of the required region, which you have added using AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods or which you have identified using the SetRegionName method.
Example





In This Topic
RemoveRegionByName Method (GdViewer)
In This Topic
Removes a highlighted region specified by its name related to the document currently displayed in the GdViewer control. These regions, if present, determines the currently defined highlighted regions on the displayed document.
Syntax
'Declaration
 
Public Function RemoveRegionByName( _
   ByVal Name As String _
) As GdPictureStatus
public GdPictureStatus RemoveRegionByName( 
   string Name
)
public function RemoveRegionByName( 
    Name: String
): GdPictureStatus; 
public function RemoveRegionByName( 
   Name : String
) : GdPictureStatus;
public: GdPictureStatus RemoveRegionByName( 
   string* Name
) 
public:
GdPictureStatus RemoveRegionByName( 
   String^ Name
) 

Parameters

Name
The name of the required region, which you have added using AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods or which you have identified using the SetRegionName method.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Be aware that if the required region does not exist, the method will fail.
Example
How to remove one or more regions using its name.
'We assume that the GdViewer1 control has been properly integrated and your document has been properly displayed as well.
            
'Here we make use of the RegionSelectedByUser event.
Sub GdViewer1_RegionSelectedByUser(ByVal RegionID As Integer)
    GdViewer1.SetRegionName(GdViewer1.GetRegionID(RegionID), "ToRemove")
End Sub
            
Sub GdViewer1_RemoveRegions()
    If GdViewer1.RegionCount() > 0 Then
        'Expecting some regions have been marked for removing using the RegionSelectedByUser event.
        Dim status As GdPictureStatus = GdViewer1.RemoveRegionByName("ToRemove")
        GdViewer1.Redraw()
        If status <> GdPictureStatus.OK Then MessageBox.Show("Removing regions has failed. Status: " & status.ToString(), "GdViewer.RemoveRegionByName")
    Else
        MessageBox.Show("No highlighted region found related to this document. Status: " & GdViewer1.GetStat().ToString(), "GdViewer.RemoveRegionByName")
    End If
End Sub
//We assume that the GdViewer1 control has been properly integrated and your document has been properly displayed as well.
            
//Here we make use of the RegionSelectedByUser event.
void GdViewer1_RegionSelectedByUser(int RegionID)
{
    GdViewer1.SetRegionName(GdViewer1.GetRegionID(RegionID), "ToRemove");
}
            
void GdViewer1_RemoveRegions()
{
    if (GdViewer1.RegionCount() > 0)
    {
        //Expecting some regions have been marked for removing using the RegionSelectedByUser event.
        GdPictureStatus status = GdViewer1.RemoveRegionByName("ToRemove");
        GdViewer1.Redraw();
        if (status != GdPictureStatus.OK)
            MessageBox.Show("Removing regions has failed. Status: " + status.ToString(), "GdViewer.RemoveRegionByName");
    }
    else
        MessageBox.Show("No highlighted region found related to this document. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.RemoveRegionByName");
}
See Also