按钮从文本框中删除焦点c#

按钮从文本框中删除焦点c#

本文介绍了按钮从文本框中删除焦点c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好, 我用c#中的按钮制作了一个键盘(触摸屏)我想写按钮点击功能作为退格键但每次按下backspace我专注的texbox失去了它的焦点创建错误只需键盘就好了Hello,I have made a keyboard(touchscreen) out of buttons in c# I want to write the function for button click as backspace but every time I press backspace my focused texbox loosing its focus creating errors working with just keyboard it fineint index = focusedTextbox.SelectionStart; focusedTextbox.Text = focusedTextbox.Text.Remove(focusedTextbox.SelectionStart - 1, 1); focusedTextbox.Select(index - 1, 1) 谢谢你的帮助thank you for your help推荐答案ButtonClickEventHandler(....){string text = focusedtextbox.Text;string newText = text.Substring(0, text.Length - 1);Dispatcher.CurrentDispatcher.BeginInvoke(() => focusedtextbox.text = newText);Dispatcher.CurrentDispatcher.BeginInvoke(() => focusedtextbox.Focus());} 这篇关于按钮从文本框中删除焦点c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 22:52