Skip to content

LoadBitmap Method

Description

Used to add an icon to the ImageManagerIcons collection of icons from a BitMap file (.BMP).

Syntax

Public Sub LoadBitmap( _
    ByVal [Path](#) As String, _
    ByVal [Commands](#) As Variant, _
    ByVal [imageState](#) As [XTPImageState](XtremeCalendarControl~Enumerations~XTPImageState_EN.md) _
)

Parameters

  • Path: The path of the BitMap to load.
  • Commands: The id that will be used to identify the icon in the collection of icons. This can be any positive (non-zero) number.
  • imageState: The state of the image.

Image States

Value Description
xtpImageNormal Specifies a normal icon. This is the image displayed when the item is displayed normally.
xtpImageDisabled Specifies a disabled icon. This is the image displayed when the item is disabled.
xtpImageHot Specifies a hot icon. This is the image displayed when the mouse pointer is positioned over the item.
xtpImageChecked Specifies a "checked" or selected icon. This is the image displayed when the item is in a selected state.
xtpImagePressed Specifies a "pressed" or pushed icon. This is the image displayed when the item is currently pressed by the mouse cursor.

Remarks

The "Commands" parameter can be any positive integer and is used to identify the icon in the collection of icons. When you want to use an icon, you need to specify this value. To use the icon, you would assign the "Commands" value to the Icon property of the GridColumn and GridRecordItem objects.

Only the "Normal" icon is used in the GridControl. You can add "Hot" and "Disabled" icons, but they will not be used.

NOTE: You will need to include the bitmap file with your application (exe) if this method is used.

Example


Figure 1 (64x16 bitmap file)


Adding an Icon with the LoadBitmap Method (Visual Basic)

This sample illustrates how to use the LoadBitmap method to add icons to the collection of icons used in the GridControl.

' 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)  
Column.Icon = 105  

wndGridControl.Icons.LoadBitmap App.Path & "\Icons\selected.bmp", 105, xtpImageNormal  
wndGridControl.Icons.LoadBitmap App.Path & "\Icons\importance.bmp", 110, xtpImageNormal  

Loading Icons Stored in a Single Bitmap File (Visual Basic)

This sample illustrates how to load multiple icons that are stored in a single Bitmap file.

' Add this to the General code section  
Const COLUMN_CHECK = 100  
Const COLUMN_IMPORTANCE = 101  
Const COLUMN_FLAG = 102  
Const COLUMN_ATTACHMENT = 103  

' There are 4 icons in the Bitmap file, the bitmap file is 64x16,  
' which contains 4 16x16 icons (See figure 1). You need to make sure that there is  
' an element in the array for each icon in the Bitmap.  
' Width of icons = Width of Bitmap / number of elements in array  
' I.e. Width of icons = 64/4 = 16  
Dim iconArray(1 To 4) As Long  
iconArray(1) = COLUMN_CHECK  
iconArray(2) = COLUMN_IMPORTANCE  
iconArray(3) = COLUMN_FLAG  
iconArray(4) = COLUMN_ATTACHMENT  

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

Set Column = wndGridControl.Columns.Add(COLUMN_CHECK, "Selected", 18, False)  
Column.Icon = COLUMN_CHECK  
Set Column = wndGridControl.Columns.Add(COLUMN_IMPORTANCE, "Importance", 18, False)  
Column.Icon = COLUMN_IMPORTANCE  
Set Column = wndGridControl.Columns.Add(COLUMN_FLAG, "Flag Status", 18, False)  
Column.Icon = COLUMN_FLAG  
Set Column = wndGridControl.Columns.Add(COLUMN_ATTACHMENT, "Attachment", 18, False)  
Column.Icon = COLUMN_ATTACHMENT  

' Passing the iconArray for the "Commands" parameter will add an icon to the collection  
' of icons for each item in the array. So Number of icons added = Number of elements in array.  
' Icon width = Total width of Bitmap/Number of elements in array.  
' The icons will be assigned the value of the array elements as an Index.  
wndGridControl.Icons.LoadBitmap App.Path & "\Icons\bmgrid.bmp", iconArray, xtpImageNormal  

See Also


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