Recently, the FindPanel of GridControl is used in project development. This allows you to filter data, but the displayed button text is in English,
Public class BuilderGridLocalizer: GridLocalizer {Dictionary <GridStringId, string> CusLocalizedKeyValue = null; /// <summary> /// constringid with parameters /// </summary> /// <param name = "cusLocalizedKeyValue"> GridStringId to be transferred, the corresponding text description </param> public BuilderGridLocalizer (Dictionary <GridStringId, string> cusLocalizedKeyValue) {CusLocalizedKeyValue = cusLocalizedKeyValue ;} /// <summary> /// heavy load /// </summary> /// <Param name = "id"> GridStringId </param> // <returns> string </returns> public override string GetLocalizedString (GridStringId) {if (CusLocalizedKeyValue! = Null) {string _ gridStringDisplay = string. empty; foreach (KeyValuePair <GridStringId, string> gridLocalizer in CusLocalizedKeyValue) {if (gridLocalizer. key. equals (id) {_ gridStringDisplay = gridLocalizer. value; break ;}} return _ gridStringDisplay;} return base. getLocalizedString (id );}}
Define a class to inherit GridLocalizer and override the GetLocalizedString method. The logic is very simple. To make it easier to reuse code and reduce repeated encoding, add a method to another class, as shown below:
/// <Summary> /// custom GridControl button text /// </summary> /// <param name = "girdview"> GridView </param> /// <param name = "cusLocalizedKeyValue"> GridStringId to be transferred, the corresponding text description </param> public static void CustomButtonText (this GridView girdview, Dictionary <GridStringId, string> cusLocalizedKeyValue) {comment _ bGridLocalizer = new comment (cusLocalizedKeyValue); GridLocalizer. active = _ bGridLocalizer ;}
The Code is as follows:
Private Dictionary <GridStringId, string> SetGridLocalizer () {Dictionary <GridStringId, string> _ gridLocalizer = new Dictionary <GridStringId, string> (); _ gridLocalizer. add (GridStringId. findControlFindButton, "Search"); _ gridLocalizer. add (GridStringId. findControlClearButton, "clear"); return _ gridLocalizer;} private void Form1_Load (object sender, EventArgs e) {Dictionary <GridStringId, string> _ gridLocalizer = SetGridLocalizer (); gridView1.CustomButtonText (_ gridLocalizer); gridControl1.DataSource = CreateTable (20); gridView1.ShowFindPanel ();}
Code effect:
. Csharpcode ,. csharpcode pre {font-size: small; color: black; font-family: Las LAS, "Courier New", courier, monospace; background-color: # ffffff; /* white-space: pre ;*/}. csharpcode pre {margin: 0em ;}. csharpcode. rem {color: #008000 ;}. csharpcode. kwrd {color: # 0000ff ;}. csharpcode. str {color: #006080 ;}. csharpcode. op {color: # effecc0 ;}. csharpcode. preproc {color: # cc6633 ;}. csharpcode. asp {background-color: # ffff00 ;}. csharpcode. html {color: #800000 ;}. csharpcode. attr {color: # ff0000 ;}. csharpcode. alt {background-color: # f4f4f4; width: 100%; margin: 0em ;}. csharpcode. lnum {color: #606060 ;}