DomainUpDown文字 [英] DomainUpDown text

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

问题描述

当表单加载时,我要突出显示第一个值文本.
当我在其他值上单击鼠标时,它们必须高亮显示..

Hi, When the form is loading I want to highlight the first value text.
When i mouse click on other value then they must get highlight..

推荐答案

暗刺您想要的内容时,高亮显示当前选定的索引文本如果更改了所选索引,则新文本将全部突出显示.
如果这是正确的,则只需使用SelectedItemChanged事件,例如;
Wild stab in the dark guess of what you want is, to highlight the currently selected index text and if the selected index is changed then the new text should be all highlighted.
If this is right then just use the SelectedItemChanged event such as;
domainUpDown1.SelectedItemChanged += new EventHandler(domainUpDown_SelectedItemChanged);


然后在事件处理程序中;


Then in the event handler;

void domainUpDown_SelectedItemChanged(object sender, EventArgs e)
{
    DomainUpDown control = sender as DomainUpDown;
    control.Select(0, control.Text.Length);
}



唯一的问题是,当控件失去焦点时,突出显示将消失,您无法采取任何措施来停止突出显示,但是如果您还使用ClickGotFocus事件,则可以在控件获得焦点时重新突出显示文本.再次.



The only problem is that when the control looses focus the highlighting will disappear, there is nothing you can do to stop that but if you also use the Click and GotFocus events you can re-highlight the text when the control receives focus again.

domainUpDown1.Click += new EventHandler(domainUpDown_Click);
domainUpDown1.GotFocus += new EventHandler(domainUpDown_GotFocus);


还有事件处理程序;


And the event handlers;

void domainUpDown_Click(object sender, EventArgs e)
{
    DomainUpDown control = sender as DomainUpDown;
    control.Select(0, control.Text.Length);
}
void domainUpDown_GotFocus(object sender, EventArgs e)
{
    DomainUpDown control = sender as DomainUpDown;
    control.Select(0, control.Text.Length);
}



如果DomainUpDown控件的TabIndex为0(零),则它将在窗体加载时突出显示,但如果不是,则它将不突出显示,因为它将不会获得焦点.



If the TabIndex of your DomainUpDown control is 0 (zero) then it will highlight on form load but if it is not then is will not as it will not gain focus.


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

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