|Color||A color expression that defines the selected items background color. The last 7 bits in the high significant byte of the color indicates the identifier of the skin being used. Use the Add method to add new skins to the control. If you need to remove the skin appearance from a part of the control you need to reset the last 7 bits in the high significant byte of the color being applied to the background's part.|
Use the SelForeColor and SelBackColor properties to define colors for the selected items. The control highlights the selected items only if the SelBackColor and BackColor properties have different values, and the SelForeColor and ForeColor properties have different values. The SelBackColor property may display transparent areas using EBN files. The SelForeColor property is applied only if it is different that the control's foreground color. Use the SingleSel property to specify whether the control supports single or multiple selection. Use the SelectItem property to programmatically select an item giving its handle. The SelectedItem and SelectCount properties get the collection of selected items. Use the FocusItem property to get the focused item. The control fires the SelectionChanged event when user changes the selection. Use the SelectableItem property to specify the user can select an item. How do I assign a new look for the selected item?
The following VB sample changes the visual appearance for the selected item. The SelBackColor property indicates the selection background color. Shortly, we need to add a skin to the Appearance object using the Add method, and we need to set the last 7 bits in the SelBackColor property indicates the index of the skin that we want to use. The sample applies the "" to the selected item(s):
With Grid1 With .VisualAppearance .Add &H23, App.Path + "\selected.ebn" End With .SelForeColor = RGB(0, 0, 0) .SelBackColor = .SelBackColor Or &H23000000 End With
The sample adds the skin with the index 35 ( Hexa 23 ), and applies to the selected item using the SelBackColor property.
The following C++ sample applies a new appearance to the selected item(s):
#include "Appearance.h" m_grid.GetVisualAppearance().Add( 0x23, COleVariant(_T("D:\\Temp\\ExGrid_Help\\selected.ebn")) ); m_grid.SetSelBackColor( m_grid.GetSelBackColor() | 0x23000000 ); m_grid.SetSelForeColor( 0 );
The following VB.NET sample applies a new appearance to the selected item(s):
With AxGrid1 With .VisualAppearance .Add(&H23, "D:\Temp\ExGrid_Help\selected.ebn") End With .SelForeColor = Color.Black .Template = "SelBackColor = 587202560" End With
The VB.NET sample uses the Template property to assign a new value to the SelBackColor property. The 587202560 value represents &23000000 in hexadecimal.
The following C# sample applies a new appearance to the selected item(s):
axGrid1.VisualAppearance.Add(0x23, "D:\\Temp\\ExGrid_Help\\selected.ebn"); axGrid1.Template = "SelBackColor = 587202560";
The following VFP sample applies a new appearance to the selected item(s):
With thisform.Grid1 With .VisualAppearance .Add(35, "D:\Temp\ExGrid_Help\selected.ebn") EndWith .SelForeColor = RGB(0, 0, 0) .SelBackColor = .SelBackColor + 587202560 EndWithHow do I assign a new look for the selected item? The component supports skinning parts of the control, including the selected item. Shortly, the idea is that identifier of the skin being added to the Appearance collection is stored in the first significant byte of property of the color type. In our case, we know that the SelBackColor property changes the background color for the selected item. This is what we need to change. In other words, we need to change the visual appearance for the selected item, and that means changing the background color of the selected item. So, the following code ( blue code ) changes the appearance for the selected item:
With Grid1 .VisualAppearance.Add &H34, App.Path + "\aqua.ebn" .SelBackColor = &H34000000 End With
Please notice that the 34 hexa value is arbitrary chosen, it is not a predefined value. Shortly, we have added a skin with the identifier 34, and we specified that the SelBackColor property should use that skin, in order to change the visual appearance for the selected item. Also, please notice that the 34 value is stored in the first significant byte, not in other position. For instance, the following sample doesn't use any skin when displaying the selected item:
With Grid1 .VisualAppearance.Add &H34, App.Path + "\aqua.ebn" .SelBackColor = &H34 End With
This code ( red code ) DOESN'T use any skin, because the 34 value is not stored in the higher byte of the color value. The sample just changes the background color for the selected item to some black color ( RGB(0,0,34 ) ). So, please pay attention when you want to use a skin and when to use a color. Simple, if you are calling &H34000000, you have 34 followed by 6 ( six ) zeros, and that means the first significant byte of the color expression. Now, back to the problem. The next step is how we are creating skins? or EBN files? The Exontrol's exbutton component includes a builder tool that saves skins to EBN files. So, if you want to create new skin files, you need to download and install the exbutton component from our web site. Once that the exbutton component is installed, please follow the steps.
Let's say that we have a BMP file, that we want to stretch on the selected item's background.
You can always open the skin with the builder and change it later, in case you want to change it.
Now, create a new project, and insert the component where you want to use the skin, and add the skin file to the Appearance collection of the object, using blue code, by changing the name of the file or the path where you have selected the skin. Once that you have added the skin file to the Appearance collection, you can change the visual appearance for parts of the controls that supports skinning. Usually the properties that changes the background color for a part of the control supports skinning as well.