Hi,
I use UltraGrid in virtual mode. I wanted to disable hottrack feature on cells, so I set CellHottrackInvalidationStyle to CellHottrackInvalidationStyle.Never.
_grid.DisplayLayout.CellHottrackInvalidationStyle = CellHottrackInvalidationStyle.Never;
Everything worked as I expected.
However, when I loaded an isl file (Office2010Black.isl or Office2010Silver.isl) by using StyleManager.Load, hottracking was unexpectedly enabled for ValueList columns. Here is the code I setup a value list to a column:
private void SetDropdownValueList(IFieldInfo fieldInfo, UltraGridColumn column) { var valueList = new BindableValueList { BindingContextControl = GridControl, DataSource = fieldInfo.DropdownValueList.ValueList }; if (!string.IsNullOrEmpty(fieldInfo.DropdownValueList.ValueMember)) valueList.ValueMember = fieldInfo.DropdownValueList.ValueMember; if (!string.IsNullOrEmpty(fieldInfo.DropdownValueList.DisplayMember)) valueList.DisplayMember = fieldInfo.DropdownValueList.DisplayMember; column.ValueList = valueList; column.Style = ColumnStyle.DropDownList; }
Could someone help me to solve this issue please?
Thanks,Shaolin
Hi Shaolin,
Thank you for posting in our forums!
Reading though your scenario, I would like to divide it into two states. The first is without a style library and the second is after loading a style library.
Without a style library
The UltraGrid has some cell hot track appearance set and you would like to have a toggle button for enabling and disabling the hot tracking on cells. The property CellHottrackInvalidationStyle only prevents the cells from redrawing themselves when it is not necessary, which improves the performance of the UltraGrid and this is its main purpose. However, it would work for your scenario as well (disabling hot tracking on cells) in the most of the cases, but not in all. For example, for value list or Boolean cells it initially will not work. Therefore, the most appropriate and convenient way of disabling hot tracking on any element is resetting it to its default value and assigning back the same appearance object when it is necessary.
Loading a style library
When a style library is loaded it is loaded with higher priority upon the appearance objects and as a result overrides all previously set appearances. Because of that, the previous approach of enabling and disabling the hot track appearance will not work. On the other hand, each style library can have many style sets. Except from styling the whole application, this allows you to style individual controls completely different than the general style. For example, you do not want to have hot track appearance in the UltraGrid, and therefore a style set with default hot track appearance is loaded. At a given moment, the hot tracking should be back and as a results a style set with hot track appearance applied is loaded back. At the following forum thread is explained how to switch between different style sets.
For further reference, please see the attached sample application and let me know if you have any additional questions regarding this matter.
Hi Ivaylo,
Thanks so much for your detailed explanation!
I modified your attached sample:
public Form1() { InitializeComponent(); string path = @"C:\Users\Public\Documents\Infragistics\2016.1\Windows Forms\Samples\Legacy\Data\StyleLibrary\Office2010Black.isl"; Infragistics.Win.AppStyling.StyleManager.Load(path); }
Your sample application did not work as expected after I loaded Office2010Black.isl. Hottracking was always enabled.
Best Regards,Shaolin
Sample application intention was to show you how to enable and disable hot track appearance without loaded style library. As I explained above you can load different style sets, in order to enable and disable the hot track appearance of the cells using a style library.
In addition to your second question. It is completely normal that the appearance objects are not honored at runtime when a style library is loaded. The idea behind the style library is to apply all appearances in design time via the AppStylist application. In case any particular appearance is modified by the loaded style library, you can’t change it at runtime.
In a summary, you have to choose between setting the appearances with or without a style library. In case you would like to use a style library, be sure that all appearances you would like to be set are included and modified in the style library file.
Let me know if you need further assistance regarding this matter.
Thanks for you reply!
Can you make some changes to an style library, for example, Office2010Black.isl to solve these two issues? I think there must be ways to get rid of appearance defined in an AppStylist.
Of course you can get rid of any appearance included as a part of the style library. Just open the ISL file with your favorite text editor and you will see that the ISL file is actually an XML based document where each style node has state child nodes. The style you should be looking for is with attribute role equal to “GridCell”. In case you don’t want the style library to override a particular appearance or an element, you can just delete the entire style node or state child node corresponding to the appearance you would like to be removed.
Thanks so much!
I had to reopen this item since you never mentioned any solution to my second issue related to AppStyling. I post a separate thread for my second issue because the second issue is more troublesome. I was even able to figure out a solution for the Hottrack issue before you post your suggestion.