Textbox类问题 [英] Textbox Class question

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

问题描述

我正在寻找创建多个文本框,在

焦点上变为淡蓝色。最有效的方法是什么?


-Peter

解决方案

我假设你在说话关于Windows窗体应用程序,对吗?


Public Sub ChangeTextBoxColor(ByVal Sender as System.Object,e as EventArgs)

_

处理Textbox1.Enter,Textbox2.Enter,Textbox3.Enter等等。


将theTB调暗为TextBox = CType(发件人,文本框)

theTB.BackColor = Color.Blue


End Sub


" Peter" < PE *** @ mclinn.com>在消息中写道

news:dc ************************** @ posting.google.c om ...

我正在寻找创建多个文本框,在
焦点上变为淡蓝色。最有效的方法是什么?

-Peter



我同意 - 或者你可以添加其他文本框在其中一个方框''输入''

事件 - 在handle子句中。

我仍​​然想念那些控制数组 - 和Recordset -

Scott M. < S - *** @ nospam.nospam>在消息中写道

news:uH ************** @ TK2MSFTNGP12.phx.gbl ...

我假设你在说话关于Windows窗体应用程序,对吧?

Public Sub ChangeTextBoxColor(ByVal Sender as System.Object,e as
EventArgs)_
Handles Textbox1.Enter,Textbox2.Enter,Textbox3 。输入等等。

将TB变暗为TextBox = CType(发件人,文本框)
theTB.BackColor = Color.Blue

End Sub

彼得 < PE *** @ mclinn.com>在消息中写道
新闻:dc ************************** @ posting.google.c om ...

我正在寻找创建多个文本框,在
焦点上变为淡蓝色。最有效的方法是什么?

-Peter




---

发送邮件经过无病毒认证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.732 /病毒数据库:486 - 发布日期:2004年7月29日


Hal,


VBNet中有很多控制数组。


我有一个完整的样本使用它,我已经贴了它。你的进入假期问题看起来非常好。只需将其复制到一个新项目并在表单上添加2

按钮和一个文本框。它是一个按钮,但是对于一个

文本框,它是一样的。


这是在VBNet中使用一组控件的一种方法。不管你怎么用
也可以用来控制control.collection。


然而控件数组的行为已经从VB6改变了什么是

有点奇怪的做法。 (更多关于某个类型的所有控件的表格

比控制数组更多,当你通过实例时你将如何处理

从一个控件继承而几乎是相同的外观)。


关于数据集你将来可能总是希望你不必再次使用记录集。


(斯科特的样本非常好,与使用数组设置处理程序的其他

方法相同,这是为了2

按钮,但可能是一堆)


我希望这能给出一些想法吗?


Cor


\\\需要两个按钮和一个表格上的标签

Private Sub Form1_Load(ByVal sender As Object,_

ByVal e As System.EventArgs)处理MyBase.Load

Dim btnArea As Button()= New Button(){Button1,Button2}

For each btn As Button在btnArea

AddHandler btn.MouseLeave,AddressOf But ton_MouseLeave

AddHandler btn.MouseEnter,AddressOf Button_MouseEnter

Next

End Sub

Private Sub Button_MouseLeave(ByVal sender As对象,_

ByVal e As System.EventArgs)

DirectCast(发件人,按钮).BackColor = Color.Black

Me.Label1。 Text =""

End Sub

Private Sub Button_MouseEnter(ByVal sender As Object,_

ByVal e As System.EventArgs)

DirectCast(发件人,按钮).BackColor = Color.Red

Me.Label1.Text = DirectCast(发件人,按钮).Name

结束Sub

结束班

///

我同意 - 或者你可以添加其他文本框到其中一个框
''输入''事件 - 在句子条款中。
我仍然想念那些控制数组 - 和Recordset -

" Scott M." < S - *** @ nospam.nospam>在消息中写道
新闻:uH ************** @ TK2MSFTNGP12.phx.gbl ...

我假设您在谈论Windows窗体应用程序,对吧?

Public Sub ChangeTextBoxColor(ByVal Sender as System.Object,e as


EventArgs)

_
Handles Textbox1 .Enter,Textbox2.Enter,Textbox3.Enter等等。

将TB变暗为TextBox = CType(发件人,文本框)
theTB.BackColor = Color.Blue

End Sub

彼得 < PE *** @ mclinn.com>在消息中写道
新闻:dc ************************** @ posting.google.c om ...

我正在寻找创建多个文本框,在
焦点上变为淡蓝色。最有效的方法是什么?

-Peter




---
发送邮件是经过认证的无病毒。
由AVG反病毒系统检查( http://www.grisoft .com)
版本:6.0.732 /病毒数据库:486 - 发布日期:2004年7月29日


I''m looking to create multiple textboxs that change to a light blue on
focus. What is the most efficient way to do this?

-Peter

解决方案

I assume you are talking about a Windows Forms application, right?

Public Sub ChangeTextBoxColor(ByVal Sender as System.Object, e as EventArgs)
_
Handles Textbox1.Enter, Textbox2.Enter, Textbox3.Enter, etc., etc.

Dim theTB as TextBox = CType(sender, Textbox)
theTB.BackColor = Color.Blue

End Sub

"Peter" <pe***@mclinn.com> wrote in message
news:dc**************************@posting.google.c om...

I''m looking to create multiple textboxs that change to a light blue on
focus. What is the most efficient way to do this?

-Peter



I agree - or you could add the other text boxes to one of the boxes ''enter''
event - in the handles clause.
I still miss those control arrays - and Recordset -
"Scott M." <s-***@nospam.nospam> wrote in message
news:uH**************@TK2MSFTNGP12.phx.gbl...

I assume you are talking about a Windows Forms application, right?

Public Sub ChangeTextBoxColor(ByVal Sender as System.Object, e as EventArgs) _
Handles Textbox1.Enter, Textbox2.Enter, Textbox3.Enter, etc., etc.

Dim theTB as TextBox = CType(sender, Textbox)
theTB.BackColor = Color.Blue

End Sub

"Peter" <pe***@mclinn.com> wrote in message
news:dc**************************@posting.google.c om...

I''m looking to create multiple textboxs that change to a light blue on
focus. What is the most efficient way to do this?

-Peter



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004


Hal,

There are a lot of control arrays in VBNet.

I have a complete sample using it, I have pasted it bellow. It looks very
much your enter leave problem. Just copy it to a new project and add 2
buttons and a textbox on the form. It is hoovering a button, however for a
textbox it goes the same.

This is one approacht of using an array of controls in VBNet. However you
can as well use for this the control.collection.

However the behaviour of control arrays has changed from VB6 what was a
little bit strange approach. (More a table of all controls of a certaintype
than a control array, how you would deal with that when you by instance
inherit from a control to make an almost the same look alike).

About the dataset you will probably in future always hope that you don''t
ever have to use the recordset again.

(The sample from Scott is very good, it is the same as this just an other
approach using the array for setting the handlers, which is here for 2
buttons, however could be a bunch)

I hope this gives some ideas?

Cor

\\\needs two buttons and a label on a form
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim btnArea As Button() = New Button() {Button1, Button2}
For Each btn As Button In btnArea
AddHandler btn.MouseLeave, AddressOf Button_MouseLeave
AddHandler btn.MouseEnter, AddressOf Button_MouseEnter
Next
End Sub
Private Sub Button_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Button).BackColor = Color.Black
Me.Label1.Text = ""
End Sub
Private Sub Button_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Button).BackColor = Color.Red
Me.Label1.Text = DirectCast(sender, Button).Name
End Sub
End Class
///

I agree - or you could add the other text boxes to one of the boxes ''enter'' event - in the handles clause.
I still miss those control arrays - and Recordset -
"Scott M." <s-***@nospam.nospam> wrote in message
news:uH**************@TK2MSFTNGP12.phx.gbl...

I assume you are talking about a Windows Forms application, right?

Public Sub ChangeTextBoxColor(ByVal Sender as System.Object, e as


EventArgs)

_
Handles Textbox1.Enter, Textbox2.Enter, Textbox3.Enter, etc., etc.

Dim theTB as TextBox = CType(sender, Textbox)
theTB.BackColor = Color.Blue

End Sub

"Peter" <pe***@mclinn.com> wrote in message
news:dc**************************@posting.google.c om...

I''m looking to create multiple textboxs that change to a light blue on
focus. What is the most efficient way to do this?

-Peter



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004



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

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