Csharp: datagridview enter Half Width and Full Width characters, csharpdatagridview
/// <Summary> /// fullwidth /// </summary> /// <param name = "unicodeString"> </param> /// <returns> </ returns> public static string FullWidthConvertor (string unicodeString) {StringBuilder sb = new StringBuilder (256); LCMapString (LOCALE_SYSTEM_DEFAULT, LCMAP_FULLWIDTH, unicodeString,-1, sb, sb. capacity); return sb. toString () ;}/// <summary> /// halfwidth // </summary> /// <param name = "unicodeString"> </param> /// <Returns> </returns> public static string HalfWidthConvertor (string unicodeString) {StringBuilder sb = new StringBuilder (256); LCMapString (LOCALE_SYSTEM_DEFAULT, LCMAP_HALFWIDTH, unicodeString,-1, sb. capacity); return sb. toString ();} private const uint LCMAP_FULLWIDTH = 0x00800000; private const uint LOCALE_SYSTEM_DEFAULT = 0x0800; private const uint LCMAP_HALFWIDTH = 0x00400000; [DllImport ("Kernel32.dll", CharSet = CharSet. unicode)] public static extern int LCMapString (uint Locale, uint dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest ); /// <summary> /// DataGridView // </summary> /// <param name = "sender"> </param> // /<param name = "e"> </param> private void dridViewRowNumberNo_EditingControlShowing (object sender, dataGridViewEditingControlShowi NgEventArgs e) {GridViewRowNumberNo dt = sender as GridViewRowNumberNo; // obtain the column number int columnIndex = dt. currentCell. columnIndex; // convert the unit lattice to TextBox tb = e. control as TextBox; // delegate the KeyPress transaction tb. keyPress + = new KeyPressEventHandler (geovindu_KeyPress );} /// <summary> /// KeyPress transaction in the unit lattice /// </summary> /// <param name = "sender"> </param> // <param name = "e"> </param> private void geovindu_KeyPress (objec T sender, KeyPressEventArgs e) {Control ctl = sender as Control; if (ctl = null) return; if (ctl. ImeMode! = ImeMode. hangul) ctl. imeMode = ImeMode. hangul; // if (e. keyChar & gt; = 65296 & e. keyChar <= 65305) {e. keyChar-= Convert. toChar (65248 );}}