Skip to content

Icon Property

Description

Id/Index of an icon stored in an ImageList/Collection of icons that is displayed in the column header.

Property Type

Read-write property

Syntax (Visual Basic)

Public Property Icon() As Long

Remarks

This is the value/index/id used to identify the icon within an ImageList/Collection of icons. The icon at the value/index/id of the ImageList/Collection of Icons will be displayed in the column header.

  • If Icons are in an ImageList: This value corresponds to an icon in the ImageList at the index specified by the Icon property. The index of an ImageList must start at 1 and increments by 1 for each additional icon.

  • If Icons are stored in the ImageManagerIcons object: This value corresponds to the Id given to the icon in the collection of icons. The id of an icon added to the ImageManagerIcons object can be any positive integer.

Example

Using/Assigning Icons from an ImageList Control (Visual Basic)

This sample illustrates how to add an icon to a GridColumn header from an ImageList control.

' Add this to the General code section  
Const COLUMN_NAME = 1  

' This code is placed in the Form_Load event  
Dim Column As GridColumn  

Set Column = wndGridControl.Columns.Add(COLUMN_NAME, "Name", 300, True)  
' The value assigned to the icon property corresponds to the index of an icon in the ImageList  
' I.e. The icon at index=1 in the ImageList will be displayed in the column header.  
Column.Icon = 1  

' The SetImageList method associates an ImageList with the GridControl  
wndGridControl.SetImageList ImageListGrid  

Using/Assigning Icons from a Collection of Icons (Visual Basic)

This sample illustrates how to add an icon to a GridColumn header from a collection of icons.

' Add this to the General code section  
Const COLUMN_CHECK = 0  

' This code is placed in the Form_Load event  
Dim Column As GridColumn  

Set Column = wndGridControl.Columns.Add(COLUMN_CHECK, "Selected", 18, False)  
' The value assigned to the Icon property is the Id given to the icon when the icon is added  
' to the collection of icons.  
Column.Icon = 105  

Dim hIcon As IPictureDisp  
Set hIcon = ImageListGrid.ListImages(1).ExtractIcon  

' The AddIcon method adds icons to the collection of images. You can reference the  
' icons by the Id assigned when you add them.  
' I.e. This icon can be referenced by setting the Icon property to 105.  
wndGridControl.Icons.AddIcon hIcon, 105, xtpImageNormal  

Using/Assigning Icons from a CommandBars ImageManager Control (Visual Basic)

This sample illustrates how to use icons added to a CommandBars ImageManager control.

' Add this to the General code section  
Const COLUMN_CHECK = 0  

' This code is placed in the Form_Load event  
Dim Column As GridColumn  

Set Column = wndGridControl.Columns.Add(COLUMN_CHECK, "Selected", 18, False)  
' The value assigned to the Icon property corresponds to the IconId of an icon in the ImageManager control  
Column.Icon = 1  

wndGridControl.Icons = ImageManager.Icons  

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.