Search code examples
model-view-controllerdevexpressxtrareport

How to show localized values for enum in XtraReport?


My enums are localized throught resx file like this

public enum MyViewModel
{ 
    [Display(Name = "resource_name", ResourceType = typeof(MyResource))]
    SomeValue,
}

which works fine everywhere but XtraReport. XtraReport will never take resource string but shows always SomeValue.

The only way I found to localize enum to report is to use reflection, get string from MyResource and send this localized string in datasource. But I believe there must be better way than such workaround for every enum in my report. Does anyone have a better idea how to accomplish this?


Solution

  • I managed to localize my enums in script throught OnBeforePrint function. Even when I don't think it's best solution and would like better way it solved my problem.