Gets or sets a user-defined image to use as the selection marker.
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterImageList
Dim value As RasterImage
instance.SelectUserImage = value
value = instance.SelectUserImage
|
Return Value
A user-defined
RasterImage to use as the selection marker.
Default value is null (Nothing in Visual Basic).
Example
Visual Basic | Copy Code |
---|
Public Sub RasterImageList_SelectUserImage(ByVal imageList As RasterImageList)
imageList.ViewStyle = RasterImageListViewStyle.Normal
Dim palette As RasterColor() = New RasterColor() {}
Dim selectImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, imageList.ItemSize.Width, imageList.ItemSize.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, palette, IntPtr.Zero, 0)
Dim hdc As IntPtr = selectImage.CreateLeadDC()
Dim g As Graphics = Graphics.FromHdc(hdc)
Dim rc As Rectangle = New Rectangle(0, 0, selectImage.ImageWidth, selectImage.ImageHeight)
g.FillRectangle(Brushes.Black, rc)
For i As Integer = 0 To 3
g.DrawEllipse(Pens.Red, rc.Left, rc.Top, rc.Width - 1, rc.Height - 1)
rc.Inflate(-1, -1)
Next i
g.Dispose()
RasterImage.DeleteLeadDC(hdc)
selectImage.Transparent = True
selectImage.TransparentColor = RasterColor.FromGdiPlusColor(Color.Black)
imageList.SelectUserImage = selectImage
End Sub
|
C# | Copy Code |
---|
/// This example will use a user-defined image as the selection marker of an <see cref="RasterImageList"/> control. public void RasterImageList_SelectUserImage(RasterImageList imageList) { // Use "Normal" view style imageList.ViewStyle = RasterImageListViewStyle.Normal; // Create the user-defined image to use as the selection marker (an ellipse) RasterColor[] palette = new RasterColor[0]; RasterImage selectImage = new RasterImage( RasterMemoryFlags.Conventional, imageList.ItemSize.Width, imageList.ItemSize.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, palette, IntPtr.Zero, 0); // Draw the ellipse IntPtr hdc = selectImage.CreateLeadDC(); Graphics g = Graphics.FromHdc(hdc); Rectangle rc = new Rectangle(0, 0, selectImage.ImageWidth, selectImage.ImageHeight); g.FillRectangle(Brushes.Black, rc); for(int i = 0; i < 4; i++) { g.DrawEllipse(Pens.Red, rc.Left, rc.Top, rc.Width - 1, rc.Height - 1); rc.Inflate(-1, -1); } g.Dispose(); RasterImage.DeleteLeadDC(hdc); // Set the transparent color selectImage.Transparent = true; selectImage.TransparentColor = RasterColor.FromGdiPlusColor(Color.Black); // Set this image as the selection marker imageList.SelectUserImage = selectImage; } |
Remarks
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