在文本框中录入显示工具提示框中、文本、提示、工具

2023-09-04 22:41:02 作者:他说我傻得可爱

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

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.

 
精彩推荐
图片推荐