GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / SetRegionSelected Method
A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods.
Set this parameter to true, if you want to select the specified region, otherwise set it to false to deselect it.
Example





In This Topic
SetRegionSelected Method (GdViewer)
In This Topic
Sets the selection status of a highlighted region specified by its unique identifier related to the document currently displayed in the GdViewer control. These regions, if present, determines the currently defined highlighted regions on the displayed document.

To select a region means that the region is visibly marked on the page with the thin red border, so its selection status is set to true. You can determine the selection of each highlighted region using the GetRegionSelected method.

You can also benefit from using the RegionSelectedByUser event.

Syntax
'Declaration
 
Public Function SetRegionSelected( _
   ByVal RegionID As Integer, _
   ByVal Selected As Boolean _
) As GdPictureStatus
public GdPictureStatus SetRegionSelected( 
   int RegionID,
   bool Selected
)
public function SetRegionSelected( 
    RegionID: Integer;
    Selected: Boolean
): GdPictureStatus; 
public function SetRegionSelected( 
   RegionID : int,
   Selected : boolean
) : GdPictureStatus;
public: GdPictureStatus SetRegionSelected( 
   int RegionID,
   bool Selected
) 
public:
GdPictureStatus SetRegionSelected( 
   int RegionID,
   bool Selected
) 

Parameters

RegionID
A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods.
Selected
Set this parameter to true, if you want to select the specified region, otherwise set it to false to deselect it.

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.

Just to inform you, that you are not allowed to change the color or the border of the selection tool.

Example
How to make visible and select the first region after the successful search.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    GdViewer1.RemoveAllRegions()
    Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True)
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If text_found AndAlso (GdViewer1.RegionCount() > 0) Then
            'The first region surely exists.
            Dim regID As Integer = GdViewer1.GetRegionID(1)
            GdViewer1.EnsureRegionVisibility(regID)
            GdViewer1.SetRegionSelected(regID, True)
        Else
            MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionSelected")
        End If
    Else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionSelected")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionSelected")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    GdViewer1.RemoveAllRegions();
    bool text_found = GdViewer1.SearchText(text_to_find, 0, true);
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (text_found && (GdViewer1.RegionCount() > 0))
        {
            //The first region surely exists.
            int regID = GdViewer1.GetRegionID(1);
            GdViewer1.EnsureRegionVisibility(regID);
            GdViewer1.SetRegionSelected(regID, true);
        }
        else
            MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionSelected");
    }
    else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionSelected");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionSelected");
See Also