Ole Jul Posted August 21, 2009 Posted August 21, 2009 I have a form with the following code: Public TourBars As New Generic.List(Of TextBox) ------------------------------------ For TourCount 0 to 9 TourBars.Add(New TextBox) With TourBars(TourCount) .Location = New Point(Xstart + SinceMidnight / 86400 * Xlength, Ystart + 2 + Yoffset * LineNo) .Height = 14 .Width = 600 * Duration / 86400 .BackColor = Color.Red .Cursor = Cursors.Hand .TabIndex = 1000 + TourCount .Multiline = True .BorderStyle = BorderStyle.None End With Me.Controls.Add(TourBars(TourCount)) AddHandler TourBars(TourCount).Click, AddressOf TourGE AddHandler TourBars(TourCount).MouseHover, AddressOf Tourshow AddHandler TourBars(TourCount).MouseLeave, AddressOf TourHide Next Please observe that the .Location data are calculated before the shown code. Based upon date/time data, the code generates red bars on my form - each position and lenght is determed by the date/time data. The AddHandler for click works great, but a bit tricky in that I am using the Me.ActiveControl.Tabindex data to determ which bar was actually clicked, but I could not find a better solution. Now I want to add a function which will display the actual date/time data when a specific bar is mouse hovered. So I need to detect the TourCount numbers specified in the AddHandler code lines when the TourGE, TourShow or TourHide events are fired. How to do that? Quote
Administrators PlausiblyDamp Posted August 21, 2009 Administrators Posted August 21, 2009 The eventhandler itself (TourGE, Tourshow and TourHide) will be defined with two parameters - the first is an object called sender by convention. This first parameter is the control that raised the event. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Ole Jul Posted August 21, 2009 Author Posted August 21, 2009 Thank's PlausiblyDamp your prompt reply. It helped a lot. I had to include my tourno as .Text for the labels and sender then reacts with that information: System.Windows.Forms.TextBox, Text: Tour6 It's was then simple to pick-out the required tour number (6 in example) May be not the most intelligent way but it works :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.