Show tooltip on textbox entry(在文本框条目上显示工具提示)
问题描述
我有一个 textbox
需要以某种方式输入数据.我已经实现了一些单元格验证技术来在输入数据后检查数据,但我想在用户输入数据之前向他们提供一些信息.
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.
为此,我想在textbox
中添加一个tooltip
,当用户进入工具箱时弹出该tooltip
,然后在他们开始输入时退出.
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.
例如我有以下代码:
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.");
}
这在用户输入 textbox
时执行,但是 tooltip
仅在鼠标悬停在 textbox
上时出现.有没有人有任何想法来解决这个问题?我认为也许 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 事件并使用以下代码:
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.
这篇关于在文本框条目上显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在文本框条目上显示工具提示
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01