ButtonBase.ImageKey Property
.NET Framework 4
Gets or sets the key accessor for the image in the ImageList.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
You need to specify the Key when you add items to the ImageList
If you find this all a bit terse, what you probably need to know is that you specify the key when you add items to the ImageList.
For example...
' Add items to the ImageList specifying the key
Dim imgList as New ImageList()
imgList.Images.Add("tick", My.Resources.tick)
imgList.Images.Add("cross", My.Resources.cross)
imgList.Images.Add("blank", My.Resources.blank)
' Assign the ImageList to a CheckBox in this case
cboxReason.ImageList = imgList
' Then using this in a CheckBox event handler
Private Sub cboxReason_CheckStateChanged(sender As Object, e As System.EventArgs) Handles cboxReason.CheckStateChanged
Select Case cboxReason.CheckState
Case CheckState.Indeterminate
cboxReason.ImageKey = "blank"
Case CheckState.Unchecked
cboxReason.ImageKey = "cross"
Case CheckState.Checked
cboxReason.ImageKey = "tick"
End Select
End Sub
- 4/16/2012
- Be the ball Danny