Go to Post All in all, you get what you celebrate. The more we celebrate the under-served parts of our team the more students step up and make that part great. - Alpha Beta [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 31-03-2012, 13:58
BlueNova's Avatar
BlueNova BlueNova is offline
Registered User
FRC #2704 (Order 2 Chaos)
Team Role: Alumni
 
Join Date: Mar 2011
Rookie Year: 2005
Location: Batavia, Illinois
Posts: 13
BlueNova is an unknown quantity at this point
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.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi