Control array in vb.net

  • Thread starter Thread starter samean
  • Start date Start date
Thar Aint Nairn
you add "ControlName.EventName" in a comma-separated list after the word
"Handles" to get similar functionality for event handling - but -

I miss it too
 
Yes thank you very much,and how about dragdrop event in control array ?
before is Control_DragDrop(index source...)...

Kindly regards,
 
Po,
Yes thank you very much,and how about dragdrop event in control array ?
before is Control_DragDrop(index source...)...

I pasted this in the other thread however the discussion did disapeared
them.

The event you take is not important, a trick using this is, make first one
event using the designer for one control and use than one of these 2 methods
for adding handlers to control events.

You have a lot of more possibilities using the control collections (arrays)
it would be endless to write them all.

I hope that one of those helps you?

Cor

Using a self made table
\\\ needs two buttons and a label on a form
Dim btnArea As Button() = New Button() {Button1, Button2}
For Each btn As Button In btnArea
AddHandler btn.MouseLeave, AddressOf Button_MouseLeave
Next
Private Sub Button_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs)
Me.Label1.Text = DirectCast(sender, Button).Name
End Sub
///
And the one I like the most using control.collection
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
last = DirectCast(sender, Control).Name
End Sub
Private Sub meGotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Control).Text = last
End Sub
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top