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?
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
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.
Hi,
Please let me know if you need my further assistance on this matter.
Thank you for using Infragistics Components.
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