在文本框中录入显示工具提示 [英] Show tooltip on textbox entry

查看:176
本文介绍了在文本框中录入显示工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本,需要以一定的方式来输入数据。我已经实现了一些细胞验证技术来检查数据已进入后,但我想给用户提供一些信息,他们进入数据之前。

I have a textbox that requires data to be entered in a certain way. I have implemented some cell validating techniques to check the data after it has been entered, but I'd like to provide the user with some information before they enter the data.

为此,我想一个提示添加到文本在弹出的用户时,进入工具箱,然后当他们开始键入退出。

To that end, I'd like to add a tooltip to the textbox that pops up when the user enters the toolbox, then exits when they begin to type.

例如我有以下的code:

For example I have the following code:

private void YearEdit_Enter(object sender, EventArgs e)
  {
        ToolTip tt = new ToolTip();
        tt.IsBalloon = true;
        tt.InitialDelay = 0;
        tt.ShowAlways = true;
        tt.SetToolTip(YearEdit, "Enter 4 digit year.");
    }

这执行,当用户进入文本,但是提示只有当鼠标悬停在出现文本。没有人有任何想法,以解决此问题?我想也许 tt.ShowAlways = TRUE 可能会奏效,但显然不是。

This executes when the user enters the textbox, however the tooltip only appears when the mouse hovers over the textbox. Does anyone have any ideas to work around this? I thought that perhaps tt.ShowAlways = true might work, but obviously not.

推荐答案

挂钩到textbox.enter事件并使用下面的code:

Hook into the textbox.enter event and use the following code:

private void textBox1_Enter(object sender, EventArgs e)
    {
        TextBox TB = (TextBox)sender;
        int VisibleTime = 1000;  //in milliseconds

        ToolTip tt = new ToolTip();
        tt.Show("Test ToolTip",TB,0,0,VisibleTime);
    }

与X / Y值播放,你要移动它。可见时间有多长,直到消失。

Play with X/Y values to move it where you want. Visible time is how long until it disappears.

这篇关于在文本框中录入显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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