Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Discussion on how to realize the switch focus of C# enter

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about the discussion on how to switch the focus of C# carriage return. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can gain something according to this article.

Discussion on the realization of C # enter switch focus, we learn that the Tab key is the default button to switch input focus in the Windows program, but using enter key to switch input focus is more in line with people's input habits. This problem is easy to solve in Delphi and VB, but it is rarely mentioned in VC. By repeatedly trying to change the focus of C#, I have found a way that may be helpful to all of you.

C # enter to switch focus implementation 1.

Appwizard in VC generates a dialog-based program. Toggle the resourseview status, insert an edit box in the dialog box, modify its styles property, and select multiline and want return.

C # enter to switch focus 2.

① adds a new class to classwizard by selecting add class, and name is defined as myedit,base class selecting edit. The rest use the default option.

② adds the message mapping function of wm-keydown to the newly generated my-edit class by adding the following code.

Oid Myedit::OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags) {/ / TODO: Add your message handler code here and/or call default if (nChar= = VK_RETURN) / / insert the opening part {CDialog* Pwnd= (CDialog*) GetParent (); / / get the dialog pointer Pwnd- > NextDlgCtrl (); / / switch to the next input focus} / / insert the end part CEditView::OnKeyDown (nChar, nRepCnt, nFlags);}

C # enter to switch focus 3.

Select the member variables option in classwizard, select the dialog class in class name, select the id number of the edit box in control ids, and then select the add variable button. In the dialog box, categary selects control, the class myedit that variable type just defined.

At this point, all the work is finished, compile and run the program, navigate to the edit box and enter the enter key to see how it works.

After reading the above, do you have any further understanding of how to implement the C# enter switch focus? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report