Go to Post Thanks everyone for being so positive- this just reaffirms why I love F.I.R.S.T. and volunteer my time to this program and the awesome students involved! - Weightmn [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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.
  #2   Spotlight this post!  
Unread 31-03-2012, 23:48
atsanders atsanders is offline
Registered User
FRC #0016
 
Join Date: Mar 2012
Location: Mountain Home, AR
Posts: 2
atsanders is an unknown quantity at this point
Re: VB Help

Private Sub BoardClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim labelClicked as String = sender.Name
End Sub
  #3   Spotlight this post!  
Unread 01-04-2012, 12:43
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
Re: VB Help

Works Great, thanks
__________________
"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

Closed Thread


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 00:44.

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