Recent project development, the use of Gridcontrol Findpanel, so that the data can be very good screening, but the display of the button text is in English,
So how do you define two button issues to match the project requirements? A search has found that using Gridlocalizer can be very well implemented:
Core code:
Public classBuildergridlocalizer:gridlocalizer {dictionary<gridstringid,string> Cuslocalizedkeyvalue =NULL;// <summary> /// constructor with parameters // </summary> /// <param name= "Cuslocalizedkeyvalue" > Need to transfer the GRIDSTRINGID, its corresponding text description </param> PublicBuildergridlocalizer (Dictionary<gridstringid,string> Cuslocalizedkeyvalue) {cuslocalizedkeyvalue = Cuslocalizedkeyvalue; }// <summary> /// heavy // </summary> /// <param name= "id" >GridStringId</param> // <returns>string</returns> Public Override stringGetlocalizedstring (Gridstringid ID) {if(Cuslocalizedkeyvalue! =NULL) {string_gridstringdisplay =string. Empty;foreach(Keyvaluepair<gridstringid,string> GridlocalizerinchCuslocalizedkeyvalue) {if(GridLocalizer.Key.Equals (ID)) {_gridstringdisplay = Gridlocalizer.value; Break; } }return_gridstringdisplay; }return Base. Getlocalizedstring (ID); } }
To define a class to inherit Gridlocalizer, overriding the Getlocalizedstring method, the logic is simple; to make it easier to reuse code later, to reduce the number of duplicate encodings, add a method to the other class as follows:
// <summary> /// Custom Gridcontrol button text // </summary> /// <param name= "Girdview" >GridView</param> /// <param name= "Cuslocalizedkeyvalue" > Need to transfer the GRIDSTRINGID, its corresponding text description </param> Public Static void Custombuttontext (Thisstring> Cuslocalizedkeyvalue) { new Buildergridlocalizer (cuslocalizedkeyvalue); gridlocalizer.active = _bgridlocalizer; }
This way we can use it very simply, the code is as follows:
PrivateDictionary<gridstringid,string> Setgridlocalizer () {dictionary<gridstringid,string> _gridlocalizer =NewDictionary<gridstringid,string> (); _gridlocalizer.add (Gridstringid.findcontrolfindbutton,"Find"); _gridlocalizer.add (Gridstringid.findcontrolclearbutton,"Empty");return_gridlocalizer; }Private voidForm1_Load (Objectsender, EventArgs e) {dictionary<gridstringid,string> _gridlocalizer = Setgridlocalizer (); Gridview1.custombuttontext (_gridlocalizer); Gridcontrol1.datasource = CreateTable (20); Gridview1.showfindpanel (); }
Code effects: