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