单击时删除默认文本框数据 [英] Removing default textbox data on click

查看:92
本文介绍了单击时删除默认文本框数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个文字框,上面写着在这里输入你的名字默认情况下插入

text - 目前,要删除此项,用户必须突出显示所有文本

并删除之前输入他们的名字 - 我看过网站一旦用户点击它,所有这些

文本就会消失 - 我该怎么做?


谢谢


Jane

Hi,

I have a textbox with the words "Enter your name here" inserted as default
text - At the moment, to remove this the user must highlight all the text
and delete before they type in their name - I''ve seen sites where all this
text dissapears as soon as the user clicks on it - how do I do that ?

Thanks

Jane

推荐答案

你可以使用文本框的GotFocus事件

" Jane Sharpe" < JS ** @ hotmail.com>在消息中写道

news:bu ********** @ hercules.btinternet.com ...
you can use the GotFocus event of the textbox
"Jane Sharpe" <JS**@hotmail.com> wrote in message
news:bu**********@hercules.btinternet.com...

我有一个文本框,其中包含在此处输入您的姓名字样。作为默认插入文本 - 目前,为了删除它,用户必须突出显示所有文本
并删除他们输入他们的名字之前 - 我已经看到所有这些文本的网站
文本一旦用户点击它就消失了 - 我该怎么做?


Hi,

I have a textbox with the words "Enter your name here" inserted as default
text - At the moment, to remove this the user must highlight all the text
and delete before they type in their name - I''ve seen sites where all this
text dissapears as soon as the user clicks on it - how do I do that ?

Thanks

Jane



虽然我可能通常不会硬编码字符串文字,但这应该是

给你开始的想法。


Private Sub TextBox1_GotFocus(ByVal sender As Object,ByVal e As

System.EventArgs)处理TextBox1.GotFocus

如果TextBox1.Text ="在此输入您的名字然后

TextBox1.Text =""

结束如果

结束子


或,保持默认文本,直到他们开始输入:

Private Sub TextBox1_GotFocus(ByVal sender As Object,ByVal e As

System.EventArgs)处理TextBox1.GotFocus

如果TextBox1.Text ="在这里输入你的名字然后

TextBox1.SelectAll()

结束如果

End Sub

" Jane Sharpe" < JS ** @ hotmail.com>在消息中写道

news:bu ********** @ hercules.btinternet.com ...
While I probably wouldn''t normally hardcode a string literal, this should
give you the idea to get started.

Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus
If TextBox1.Text = "Enter your name here" Then
TextBox1.Text = ""
End If
End Sub

Or, to keep the default text there until they start typing:
Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus
If TextBox1.Text = "Enter your name here" Then
TextBox1.SelectAll()
End If
End Sub
"Jane Sharpe" <JS**@hotmail.com> wrote in message
news:bu**********@hercules.btinternet.com...

我有一个文本框,其中包含在此处输入您的姓名字样。作为默认插入文本 - 目前,为了删除它,用户必须突出显示所有文本
并删除他们输入他们的名字之前 - 我已经看到所有这些文本的网站
文本一旦用户点击它就消失了 - 我该怎么做?


Hi,

I have a textbox with the words "Enter your name here" inserted as default
text - At the moment, to remove this the user must highlight all the text
and delete before they type in their name - I''ve seen sites where all this
text dissapears as soon as the user clicks on it - how do I do that ?

Thanks

Jane



谢谢,我打算要一个指针......现在我要再打给你另外一个美元了!


我收到这个错误...


Handles子句需要一个WithEvents变量





Philip Rieck < ST *** @ mckraken.com>在消息中写道

新闻:eH ************** @ tk2msftngp13.phx.gbl ...
Thanks, I was going to ask for a pointer..... now I''m going to ask for
another !

I get this error...

Handles clause requires a WithEvents variable

Jane

"Philip Rieck" <st***@mckraken.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
虽然我可能不会'通常硬编码一个字符串文字,这应该给你开始的想法。

Private Sub TextBox1_GotFocus(ByVal sender As Object,ByVal e As
System.EventArgs)处理TextBox1.GotFocus
如果TextBox1.Text =在这里输入你的名字然后
TextBox1.Text =""
结束如果
结束子

或者,保持默认文本,直到他们开始输入:
Private Sub TextBox1_GotFocus(ByVal sender As Object,ByVal e As
System.EventArgs)处理TextBox1.GotFocus
如果TextBox1.Text ="在此输入您的名字然后
TextBox1.SelectAll()
结束如果
结束Sub

" Jane Sharpe" < JS ** @ hotmail.com>在消息中写道
新闻:bu ********** @ hercules.btinternet.com ...
While I probably wouldn''t normally hardcode a string literal, this should
give you the idea to get started.

Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus
If TextBox1.Text = "Enter your name here" Then
TextBox1.Text = ""
End If
End Sub

Or, to keep the default text there until they start typing:
Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus
If TextBox1.Text = "Enter your name here" Then
TextBox1.SelectAll()
End If
End Sub
"Jane Sharpe" <JS**@hotmail.com> wrote in message
news:bu**********@hercules.btinternet.com...


我有一个带有在此处输入您的姓名字样的文本框插入为
默认文本 - 目前,要删除此项,用户必须突出显示所有
文本并在他们输入名称前删除 - 我看过所有
的网站本文一旦用户点击它就消失了 - 我该怎么做?


Hi,

I have a textbox with the words "Enter your name here" inserted as default text - At the moment, to remove this the user must highlight all the text and delete before they type in their name - I''ve seen sites where all this text dissapears as soon as the user clicks on it - how do I do that ?

Thanks

Jane




这篇关于单击时删除默认文本框数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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