Queries the specified location to determine if the point is over an IImageListItem.
public int HitTest(Point point)
Public Function HitTest( _ByVal point As Point _) As Integer
public:int HitTest(Point point)
point
The horizontal and vertical position of the coordinate in client coordinates.
The index of the item in ItemsSource under the given location, or -1 if no IImageListItem is under the location.
Imports Leadtools.Windows.ControlsImports Leadtools.CodecsImports LeadtoolsPrivate Class MyWindow3 : Inherits WindowPrivate imageList As ImageListPublic Sub New(ByVal title As String)title = title' Set the size of the formWidth = 400Height = 200' Create a new ImageList controlimageList = New ImageList()imageList.Background = Brushes.RedimageList.SelectionMode = SelectionMode.SingleimageList.Width = WidthimageList.Height = HeightContent = imageList' Create three itemsDim imagesPath As String = LEAD_VARS.ImagesDirFor i As Integer = 0 To 2' Load the imageDim index As Integer = i + 1Dim imageFileName As String = Path.Combine(imagesPath, "ImageProcessingDemo\Image" & index.ToString() & ".jpg")Dim item As ImageListItem = New ImageListItem()item.Source = New BitmapImage(New Uri(imageFileName))item.Text = "item" & index.ToString()' Select the first itemIf i = 0 Thenitem.IsSelected = TrueEnd If' Add the item to the image listimageList.Items.Add(item)Next i' Add a handler to the MouseDown eventAddHandler imageList.PreviewMouseDown, AddressOf ImageList_MouseDownEnd SubPrivate Sub ImageList_MouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)' Check for right button clicksIf e.RightButton = MouseButtonState.Pressed Then' Check if any item is under the cursor poisitionDim imageList As ImageList = TryCast(sender, ImageList)Dim item As ImageListItem = TryCast(imageList.Items(imageList.HitTest(e.GetPosition(imageList))), ImageListItem)If Not item Is Nothing Then' Yes, show the item text in a message boxMessageBox.Show(Me, item.Text)End IfEnd IfEnd SubEnd ClassPublic Sub ImageList_HitTest(ByVal title As String)Dim window As MyWindow3 = New MyWindow3(title)window.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Help;using Leadtools.Windows.Controls;using Leadtools;using Leadtools.Codecs;class MyWindow3 : Window{ImageList imageList;public MyWindow3(string title){Title = title;// Set the size of the formWidth = 400;Height = 200;// Create a new ImageList controlimageList = new ImageList();imageList.Background = Brushes.Red;imageList.SelectionMode = SelectionMode.Single;imageList.Width = Width;imageList.Height = Height;Content = imageList;// Create three itemsstring imagesPath = LEAD_VARS.ImagesDir;for (int i = 0; i < 3; i++){// Load the imageint index = i + 1;string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".jpg");ImageListItem item = new ImageListItem();item.Source = new BitmapImage(new Uri(imageFileName));item.Text = "item" + index.ToString();// Select the first itemif (i == 0)item.IsSelected = true;// Add the item to the image listimageList.Items.Add(item);}// Add a handler to the MouseDown eventAddHandler(ImageListItem.MouseDownEvent, new MouseButtonEventHandler(ImageList_MouseDown));imageList.PreviewMouseDown += new MouseButtonEventHandler(ImageList_MouseDown);}private void ImageList_MouseDown(object sender, MouseButtonEventArgs e){// Check for right button clicksif (e.RightButton == MouseButtonState.Pressed){// Check if any item is under the cursor poisitionImageList imageList = sender as ImageList;ImageListItem item = imageList.Items[imageList.HitTest(e.GetPosition(imageList))] as ImageListItem;if (item != null){// Yes, show the item text in a message boxMessageBox.Show(this, item.Text);}}}}public void ImageList_HitTest(string title){MyWindow3 window = new MyWindow3(title);window.ShowDialog();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow3 : ChildWindow{ImageList imageList;public MyWindow3(string title){Title = title;// Set the size of the formWidth = 400;Height = 200;// Create a new ImageList controlimageList = new ImageList();imageList.Background = new SolidColorBrush(Colors.Red);imageList.SelectionMode = SelectionMode.Single;imageList.Width = Width;imageList.Height = Height;Content = imageList;// Create three itemsstring imagesPath = LeadtoolsExamples.Common.ImagesPath.Path;for (int i = 0; i < 3; i++){// Load the imageint index = i + 1;string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg";ImageListItem item = new ImageListItem();item.Source = new BitmapImage(new Uri(imageFileName));item.Text = "item" + index.ToString();// Select the first itemif (i == 0)item.IsSelected = true;// Add the item to the image listimageList.Items.Add(item);}// Add a handler to the MouseDown eventAddHandler(ImageListItem.MouseLeftButtonDownEvent, new MouseButtonEventHandler(imageList_MouseLeftButtonDown), false);imageList.MouseLeftButtonDown +=new MouseButtonEventHandler(imageList_MouseLeftButtonDown);}void imageList_MouseLeftButtonDown(object sender, MouseButtonEventArgs e){// Check if any item is under the cursor positionImageList imageList = sender as ImageList;ImageListItem item = imageList.Items[imageList.HitTest(e.GetPosition(imageList))] as ImageListItem;if (item != null){// Yes, show the item text in a message boxMessageBox.Show(item.Text);}}}public void ImageList_HitTest(string title){MyWindow3 window = new MyWindow3(title);window.Show();}
Imports Leadtools.Windows.ControlsPrivate Class MyWindow3 : Inherits ChildWindowPrivate imageList As ImageListPublic Sub New(ByVal title As String)title = title' Set the size of the formWidth = 400Height = 200' Create a new ImageList controlimageList = New ImageList()imageList.Background = New SolidColorBrush(Colors.Red)imageList.SelectionMode = SelectionMode.SingleimageList.Width = WidthimageList.Height = HeightContent = imageList' Create three itemsDim imagesPath As String = LeadtoolsExamples.Common.ImagesPath.PathFor i As Integer = 0 To 2' Load the imageDim index As Integer = i + 1Dim imageFileName As String = imagesPath & "Image" & index.ToString() & ".jpg"Dim item As ImageListItem = New ImageListItem()item.Source = New BitmapImage(New Uri(imageFileName))item.Text = "item" & index.ToString()' Select the first itemIf i = 0 Thenitem.IsSelected = TrueEnd If' Add the item to the image listimageList.Items.Add(item)Next i' Add a handler to the MouseDown eventAddHandler imageList.MouseLeftButtonDown, AddressOf imageList_MouseLeftButtonDownEnd SubPrivate Sub imageList_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)' Check if any item is under the cursor positionDim imageList As ImageList = TryCast(sender, ImageList)Dim item As ImageListItem = TryCast(imageList.Items(imageList.HitTest(e.GetPosition(imageList))), ImageListItem)If Not item Is Nothing Then' Yes, show the item text in a message boxMessageBox.Show(item.Text)End IfEnd SubEnd ClassPublic Sub ImageList_HitTest(ByVal title As String)Dim window As MyWindow3 = New MyWindow3(title)window.Show()End Sub
|
Products |
Support |
Feedback: HitTest(Point) Method - Leadtools.Windows.Controls |
Introduction |
Help Version 19.0.2017.3.22
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.