Csharp: datagridview enter Half Width and Full Width characters, csharpdatagridview

Source: Internet
Author: User

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 );}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.