|
VB Help
Crazy Original Idea here (ok, not very crazy... or original... but still useful)
A spot to put any questions/advice for programming in VB
I'll Start.
I currently have a program where I create labels in code, and then using the "addhandler" function, set it so that when you click on those labels, they trigger the "boardclick" function. My question is: how do I know which label I clicked on (I have 100 different labels)?
I have a working solution of getting the mouse position when you click on them, and then figuring it out based off of that, but I'm looking for something more elegant.
My code looks like this:
For X = 0 To 9
For Y = 0 To 9
GameBoard(X, Y) = New Label
'Go through and set properties such as size, color, position, etc.
pnlBoard.Controls.Add(GameBoard(X, Y))
AddHandler GameBoard(X, Y).Click, AddressOf BoardClick
Next
Next
Private Sub BoardClick()
'Insert Code Here
'As you can see, I have 100 labels that could possibly trigger this event, I want to know which one it was, any suggestions?
End Sub
__________________
"We're all nerds here, no need to be socially awkward"
"Oh, you want to know what I would do? I'd make a helicopter."
Once a FIRST Student, ALWAYS a FIRST Student
Last edited by BlueNova : 31-03-2012 at 14:07.
|