检测聚焦文本框 [英] detect the focused textbox

查看:64
本文介绍了检测聚焦文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友,



我有10个文本框和一个按钮,考虑到我的光标在第5个文本框中闪烁。当我点击按钮时,我应该找到光标所在的文本框并在该文本框中写入一些文本..我不知道如何检测聚焦文本框..

解决方案

你无法检测到之前聚焦的文本框 - 因为它不再被聚焦 - 但你可以处理TextBox.Leave事件并设置一个变量来告诉你它是哪一个。

  private  TextBox lastLeft; 
private void myTextBoxes_Leave( object sender,EventArgs e)
{
lastLeft = sender as TextBox;
}


它可能被索引为0或1,检查html代码!

修改所有索引控件...

Hi Friends,

I have some 10 number of textbox and a button, consider my cursor is blinking in 5th textbox. when i click the button ,i should find in which textbox the cursor was and write some text in that textbox.. i dono how to detect the focused textbox..

解决方案

You can''t detect the previous focussed textbox - because it is no longer focussed - but you can handle the TextBox.Leave event and set a variable to tell you which one it was.

private TextBox lastLeft;
private void myTextBoxes_Leave(object sender, EventArgs e)
    {
    lastLeft = sender as TextBox;
    }


It''s possibly indexed as 0 or 1, check html code!
Modify all indexed controls...


这篇关于检测聚焦文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆