[C#] Set the input method to solve the problem of abnormal recognition of the scanner in the Chinese state

series of articles

[C#] Number generator (defining order number rules, fixed characters, serial number, business order number)
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/129129787

[C#] Date range generator (start date, end date)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/129040663

[C#] Component-based development, call dll component method
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/129492112

[C#] Use of data entity classes
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/128816638

[C#] Document Approval Flow Scheme
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/128972545

[C#] Barcode Management Operation Manual
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/126589496

[C#] WebAPI publishing and exception handling under the IIS platform
: https://blog.csdn.net/youcheng_ge/article/details/126539836

[C#] Code Template Generation Tool
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/126890673

[C#] MySQL database import tool (batch Excel insertion)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/126427323

[C#] Simple QR code creation and printing tool
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/126884228

[C#] The most complete document printing (print template, barcode & QR code, font style, project source code)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/129415723

[C#] Windows service (Service) installation and start-stop solution
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/124053794

[C#] Penetrate Session isolation, service calls external programs (no form interface solution)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/124053033

[C#] Task plan implementation, using the Quartz class
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/123667723

[C#] Source Code Parsing Regular Expression
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/118337074

[C#] Software version and file MD5 record (XML operation)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/112513871

[C#] Test whether the network is connected
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/110137288

[C#] Get the code according to the name (Dictionary get key method)
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/129816701

[C#] Data modeling, do you use DataTable or List?
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/129792726

[C#] Two-way binding between the GridControl control and
the dataset

[C#] GridControl dynamically replaces DataSource, data query exception handling
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/130305424

[C#] GridControl date field displays hours, minutes and seconds
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/130718303

[C#] GridControl adds a selection column (no need for a second click)
link to this article: https://blog.csdn.net/youcheng_ge/article/details/130763713

[C#] Database checking tool (cross-library access)
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/97172329

[C#] Code Analysis – Print Dataset
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/131431829

[C#] Code Analysis – Intercept the entire method function
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/109817809

[C#] Reflection mechanism, dynamic loading of class files
Link to this article: https://blog.csdn.net/youcheng_ge/article/details/131435110



foreword

I can abstract the whole world, but I cannot abstract you. Wants to make you a private constant so outside functions can't access you. I also want you to be a global constant so that I can call you throughout my lifetime. It's a pity that there is no such constant in the world, and I can't define you, because you are so specific in my heart.

Hello everyone, this column is the [Project Actual Combat] column, which is different from the [Underlying Library] column. We can find that the chapters "Problem Description" and "Project Display" have been added, which is very in line with the project development process and allows readers to understand the project more clearly. The problem to be solved, and the effect that the product can achieve. This column contains solutions to the project development process, which is the refinement of relatively mature and reliable methods for my project development. I will sort out the solutions to these problems and write this article to share with you. If you encounter similar problems, you can deal with them according to the solution in this article.

This column will continue to be updated and improved, and the column articles are weakly related (the dependencies between articles are weak, and there is no reading order). If you have any questions, you can private message me. If you are interested in this column, please pay attention. I will show you how to use the most concise code to realize complex functions.

·提示:本专栏为项目实战篇,未接触项目开发的同学可能理解困难,不推荐阅读。
3A0N000001


1. Problem description

[C#] Set the input method to solve the problem of abnormal recognition of the scanner in the Chinese state

Two, the solution

When the text input box is focused, switch the input method to English. This can ensure the correctness of the barcode scanner recognition.

3. Software development (source code)

3.1 Set the system input method

 //函数内容: 函数方法,设置系统输入法
 //函数版本: 0.0.0.0
 //修改时间: 2023.07.12
 //修改人:gyc
 //============================================================================================
 //注意事项:
 //1.语言项,如zh-CN,en-US
 //2.
 //============================================================================================
 private void InitializeInputLanguage(string cultureType)
 {
    
    
     //获取系统中已经安装的文字输入法
     InputLanguageCollection MyInputs = InputLanguage.InstalledInputLanguages;
     //遍历获取英文输入法索引值

     for (int i = 0; i < MyInputs.Count; i++)
     {
    
    
         if (MyInputs[i].Culture.IetfLanguageTag == cultureType)
         {
    
    
             //获取英文输入法
             InputLanguage enInput = InputLanguage.InstalledInputLanguages[i];
             //设置为当前输入法
             InputLanguage.CurrentInputLanguage = enInput;
             break;
         }
     }
 }

3.2 Text input box Enter event

The text input box gets the focus, use Enter()or GotFocus()event, it is recommended to use Enter().
Binding event:

 this.baseDataInput_ReadLabel.Enter += new System.EventHandler(this.baseDataInput_ReadLabel_Enter);

Call method:

 private void baseDataInput_ReadLabel_Enter(object sender, EventArgs e)
 {
    
    
     this.baseDataInput_ReadLabel.ImeMode = System.Windows.Forms.ImeMode.Disable;
     InitializeInputLanguage("en-US");
 }

3.3 Add English input method

On some computers, the English input method is not installed, and it needs to be installed, otherwise the program will not see the effect.
Operation steps: All Settings –> Language –> Add Preferred Language –> English.

insert image description here

4. Project display

insert image description here

5. Resource Links

none

Guess you like

Origin blog.csdn.net/youcheng_ge/article/details/131677100