Hello,
we have columns or individual cell that have been set to use a dropdown list like this (column case):
column.EditorComponent = null; column.Style = ColumnStyle.DropDownList; column.ButtonDisplayStyle = ButtonDisplayStyle.OnCellActivate; column.ValueList = GetOrCreateValueList(layout, key); // some method to build a value list
In case we run in a Chinese UI culture we want to set a dedicated font. To achieve this we set a couple of appearance overrides in a handler of the InitializeLayout event:
eventArgs.Layout.Override.CellAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.ActiveRowAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.EditCellAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.SelectedRowAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.RowAppearance.FontData.Name = "Microsoft Yahei";
eventArgs.Layout.Override.ActiveRowCellAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.FixedCellAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.FixedRowAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.FixedRowCellAppearance.FontData.Name = "Microsoft Yahei"; eventArgs.Layout.Override.ReadOnlyCellAppearance.FontData.Name = "Microsoft Yahei";
Now the problem: the cells/columns that have the dropdown list style set use the wrong font in the following cases:
- when the row is not selected
- in the drop down list
Do you have a suggestion how I can make sure that the font is properly I set in the two cases?
I tried to get a reference to the EditorWithCombo instance after setting the column.Style property but I don't know how to set the font family there and if that would help to solve the issues anyway.
Thanks and best regards
Uwe
Thank you for contacting Infragistics Support.
You are on the right way. In order to set the font of the dropdown list you need to set the Appearance property of your ValueList. Please not it is a good practice to reuse Appearance object. You may find more information about this topic by following the next link http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=WinGrid_Memory_Usage.html
Please find attached a sample solution implementing this approach and let me know if this is what you are looking for or if I am missing something.
Hello Milko,
thanks for the fast response. Your sample looks as expected (I set the text and font as required in my application and it renders as expected). However, integrating this into the "real" application didn't resolve the issue. There seems to be "something else" that overrides the appearance I have set on the ValueList (when I use HawkEye to retrieve the properties of the ActiveCell I can see that the Appearance of the ValueListResolved property has the correct font set - nevertheless it is not used for rendering).
Is there anything specific I could look out for, i.e. what could override the font property that I have set on a ValueList explicitly as you proposed?
Sorry for not replying earlier. No - I don't need further assistance. Removing the font name/family definition from the style file and setting the font family for the ValueList.Appearance solved the issues.
Thanks again
Hi,
Please let me know if you need my further assistance on this matter.
Thank you for using Infragistics Components.
Thank you for your feedback.
You are correct. Each ValueListItem has its own appearance. If you set this appearance it will takes precedence over the ValueList’s appearance. Actually appearances works hierarchically, e.g. in UltraGrid cell appearance will takes precedence over column appearance, while column appearance will takes precedence over row appearance and so on. Please note if you set appearance to ValueList this appearance will apply to each ValuListItem as long as ValueListItems appearance is set to default. More about appearance hierarchies you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2014.2/CLR4.0/html/WinGrid_Appearance_and_Override_Hierarchies.html
If you have appearance set to your ValueListItems and you cannot find it in your code it could be set through Style library. If you are using AppStylist to style your application please try to deactivate any styles applied and check if this will solve your issue. Another approach is to call ResetAppearance() to each ValueListItem.
Please let me know if you need any further assistance.
Final update: the reason why setting the font in the ValueList was not effective is that the font for the ValueListItems was overriden in a style file. When I remove that definition the font is properly set.
Nevertheless your suggestion is required to make this work - so I mark this as answer.
More information:
The ValueListItems obviously have an individual appearance which is a separate instance and doesn't inherit the Font property of the ValueList itself. As soon as I set the property for the ValueListItem the correct font is used. In the test application this is not an issue (items have Default property for Font - nevertheless the correct font is used). However, I noticed another difference. In our application the value lists are not created as through the constructor but by adding the key of the ValueList to the ValueLists collection of the UltraGridLayout object which is passed in during the InitializeLayout event handling. Second difference is that items are added after the ValueList is attached to the column.
Nevertheless both items don't make a difference in the test app - I adjusted it to by identical in these aspects i.e. created the ValueList through the Layout.Add() method and attached it to the Column before adding items. Still the font is good in the test app.
Any other idea what I should look for? I don't that it is the recommended approach to set the appearance on very item in the ValueList.
Thanks