Leadtools.WinForms Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
GetItemRectangle Method
See Also  Example
Leadtools.WinForms Namespace > RasterImageList Class : GetItemRectangle Method



item
The item within the RasterImageList whose bounding rectangle you want to retrieve.
Retrieves the bounding rectangle for a specific item within the RasterImageList control.

Syntax

Visual Basic (Declaration) 
Public Function GetItemRectangle( _
   ByVal item As RasterImageListItem _
) As Rectangle
Visual Basic (Usage)Copy Code
Dim instance As RasterImageList
Dim item As RasterImageListItem
Dim value As Rectangle
 
value = instance.GetItemRectangle(item)
C# 
public Rectangle GetItemRectangle( 
   RasterImageListItem item
)
C++/CLI 
public:
Rectangle GetItemRectangle( 
   RasterImageListItem^ item
) 

Parameters

item
The item within the RasterImageList whose bounding rectangle you want to retrieve.

Return Value

A Rectangle that represents the bounding rectangle of the specified RasterImageListItem.

Example

This example will highlight the position of all visible items a RasterImageList control.

Visual BasicCopy Code
Public Sub RasterImageList_GetItemRectangle(ByVal imageList As RasterImageList)
    ' Loop through all items
    For Each item As RasterImageListItem In imageList.Items
        ' Get the item bounding rectangle
        Dim rc As Rectangle = imageList.GetItemRectangle(item)
        ' If this rectangle is visible, highlight it
        If imageList.ClientRectangle.IntersectsWith(rc) Then
            ' Convert the rectangle to screen coordinates
            rc = imageList.RectangleToScreen(rc)
            ControlPaint.DrawReversibleFrame(rc, Color.Transparent, FrameStyle.Thick)
        End If
    Next item
End Sub
C#Copy Code
public void RasterImageList_GetItemRectangle(RasterImageList imageList) 

   // Loop through all items 
   foreach(RasterImageListItem item in imageList.Items) 
   { 
      // Get the item bounding rectangle 
      Rectangle rc = imageList.GetItemRectangle(item); 
      // If this rectangle is visible, highlight it 
      if(imageList.ClientRectangle.IntersectsWith(rc)) 
      { 
         // Convert the rectangle to screen coordinates 
         rc = imageList.RectangleToScreen(rc); 
         ControlPaint.DrawReversibleFrame(rc, Color.Transparent, FrameStyle.Thick); 
      } 
   } 
}

Remarks

The bounding rectangle returned by this method represents the entire item.

The bounding rectangle that this method returns could contain a negative position or could be outside the client rectangle of the control. The exact position of the item depends on the current size of the control as well as the current scroll position.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also