本示例展示了如何把 XtraGrid 控件的默认资源 (English (美国) culture),替换为它们的等价符号。 例如, 你可以把在网格控件的自定义筛选对话框中使用的字符串 "equals",修改为数字等号 "=",如下所示:

C#CopyCode image复制代码
private void Form1_Load(object sender, System.EventArgs e) {
   GridLocalizer.Active = new MyGridLocalizer();
}

public class MyGridLocalizer : GridLocalizer {
   public override string GetLocalizedString(GridStringId id) {
      string ret = "";
      switch(id) {
         // ...
         case GridStringId.CustomFilterDialogConditionEQU : return "=";
         case GridStringId.CustomFilterDialogConditionNEQ : return "<>";
         case GridStringId.CustomFilterDialogConditionGT : return ">";
         case GridStringId.CustomFilterDialogConditionGTE : return ">=";
         case GridStringId.CustomFilterDialogConditionLT : return "<";
         case GridStringId.CustomFilterDialogConditionLTE : return "<=";
         // ...
         default:
            ret = "";
            break;
      }
      return ret;
   }
}
Visual BasicCopyCode image复制代码
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
   GridLocalizer.Active = New MyGridLocalizer()
End Sub

Public Class MyGridLocalizer
   Inherits GridLocalizer
   Public Overrides Function GetLocalizedString(ByVal id As GridStringId) As String
      Dim ret As String = ""
      Select Case id
         ' ...
         Case GridStringId.CustomFilterDialogConditionEQU : Return "="
         Case GridStringId.CustomFilterDialogConditionNEQ : Return "<>"
         Case GridStringId.CustomFilterDialogConditionGT : Return ">"
         Case GridStringId.CustomFilterDialogConditionGTE : Return ">="
         Case GridStringId.CustomFilterDialogConditionLT : Return "<"
         Case GridStringId.CustomFilterDialogConditionLTE : Return "<="
         ' ...
         Case Else
            ret = ""
      End Select
      Return ret
   End Function
End Class

结果显示如下:

Note注意

要获得更多关于本地化的信息、以及关于本地化 DevExpress 组件必需的特定 Localizer 类的信息, 请参阅 本地化 DevExpress .NET Windows 窗体控件 文档。