Gets or sets whether automatic item selection is allowed.
public RasterImageListSelectionMode SelectionMode { get; set; } Public Property SelectionMode As Leadtools.Winforms.RasterImageListSelectionMode public:property Leadtools.Winforms.RasterImageListSelectionMode SelectionMode {Leadtools.Winforms.RasterImageListSelectionMode get();void set ( Leadtools.Winforms.RasterImageListSelectionMode );}
An RasterImageListSelectionMode enumeration that indicates whether automatic item selection is allowed. Default value is RasterImageListSelectionMode.Single.
If automatic item selection is enabled, items are automatically selected and de-selected when the user clicks on them using the mouse or when moving the current selected item using the keyboard.
For more information, refer to the RasterImageListSelectionMode enumeration.
This example shows how to perform manual selection on a RasterImageList control.
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;class MyForm5 : Form{RasterImageList imageList;RasterCodecs codecs;public MyForm5(string title){Text = title;// Set the size of the formSize = new Size(400, 200);// Create a new RasterImageList controlimageList = new RasterImageList();imageList.Dock = DockStyle.Fill;imageList.SelectionMode = RasterImageListSelectionMode.Single;imageList.Size = Size;Controls.Add(imageList);imageList.BringToFront();codecs = new RasterCodecs();// 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() + ".cmp");RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);RasterImageListItem item = new RasterImageListItem(image, 1, "Item" + index.ToString());// Select the first itemif (i == 0)item.Selected = true;// Add the item to the image listimageList.Items.Add(item);}// Use manual selectionimageList.SelectionMode = RasterImageListSelectionMode.None;// Add a handler to the MouseDown eventimageList.MouseDown += new MouseEventHandler(rasterImageList_MouseDown);// Add the RasterImageList to the control collection.Controls.Add(imageList);}private void rasterImageList_MouseDown(object sender, MouseEventArgs e){RasterImageList imageList = sender as RasterImageList;// Check if we are in manual selection mode and if this is a left button clickif (imageList.SelectionMode == RasterImageListSelectionMode.None &&e.Button == MouseButtons.Left){// Yes, get the item under the cursor positionRasterImageListItem item = imageList.HitTest(e.X, e.Y);// If not already selected, select this itemif (item != null && !item.Selected){imageList.BeginUpdate();// First, de-select any itemsimageList.SelectAll(false);// Now select this itemitem.Selected = true;imageList.EndUpdate();item.Invalidate();}}}}public void RasterImageList_SelectionMode(string title){MyForm5 form = new MyForm5(title);form.ShowDialog();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports Leadtools.WinFormsImports LeadtoolsImports Leadtools.CodecsImports Leadtools.DrawingPrivate Class MyForm5 : Inherits FormPrivate imageList As RasterImageListPrivate codecs As RasterCodecsPublic Sub New(ByVal title As String)Text = title' Set the size of the formSize = New Size(400, 200)' Create a new RasterImageList controlimageList = New RasterImageList()imageList.Dock = DockStyle.FillimageList.SelectionMode = RasterImageListSelectionMode.SingleimageList.Size = SizeControls.Add(imageList)imageList.BringToFront()codecs = New RasterCodecs()' 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() & ".cmp")Dim image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)Dim item As RasterImageListItem = New RasterImageListItem(image, 1, "Item" & index.ToString())' Select the first itemIf i = 0 Thenitem.Selected = TrueEnd If' Add the item to the image listimageList.Items.Add(item)Next i' Use manual selectionimageList.SelectionMode = RasterImageListSelectionMode.None' Add a handler to the MouseDown eventAddHandler imageList.MouseDown, AddressOf rasterImageList_MouseDown' Add the RasterImageList to the control collection.Controls.Add(imageList)End SubPrivate Sub rasterImageList_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)Dim imageList As RasterImageList = CType(IIf(TypeOf sender Is RasterImageList, sender, Nothing), RasterImageList)' Check if we are in manual selection mode and if this is a left button clickIf imageList.SelectionMode = RasterImageListSelectionMode.None AndAlso e.Button = Windows.Forms.MouseButtons.Left Then' Yes, get the item under the cursor positionDim item As RasterImageListItem = imageList.HitTest(e.X, e.Y)' If not already selected, select this itemIf Not item Is Nothing AndAlso (Not item.Selected) ThenimageList.BeginUpdate()' First, de-select any itemsimageList.SelectAll(False)' Now select this itemitem.Selected = TrueimageList.EndUpdate()item.Invalidate()End IfEnd IfEnd SubEnd ClassPublic Sub RasterImageList_SelectionMode(ByVal title As String)Dim form As MyForm5 = New MyForm5(title)form.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
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
