I understand that if i call a subroutine from a control the subroutine refers to the control that called it using sender. What i don't understand however is how exactly to implement this...
Say for instance i have the code below, which creates a dynamic textbox or a dynamic picturebox with the handler of check_click.
and in check click i need to be be to gather information on the sender in order to resize and manipulate it, how would i go about it?
Below is what i have in check_click...( not much)
Say for instance i have the code below, which creates a dynamic textbox or a dynamic picturebox with the handler of check_click.
Code:
Public Sub doall_click(ByVal sender As Object, ByVal e As EventArgs) If Tool = "Text" Then 'define varibles intelement = intelement + 1 CursorOffset = Windows.Forms.Cursor.Position intheight = (Me.Height - dynpan(1).Height) / 2 intwidth = (Me.Width - dynpan(1).Width) / 2 sintxtsize = txtsize.Text 'make space ReDim Preserve dynlabel(intelement) 'create new label and define propeties Me.Controls.Add(dynlabel(intelement)) dynlabel(intelement) = New TextBox dynlabel(intelement).Location = New Point((CursorOffset.X), (CursorOffset.Y)) dynlabel(intelement).BorderStyle = BorderStyle.None dynlabel(intelement).BackColor = Pan2color.BackColor dynlabel(intelement).ForeColor = Pan1color.BackColor dynlabel(intelement).Parent = dynpan(intlayeron) dynlabel(intelement).Text = "TYPE HERE" dynlabel(intelement).Tag = intelement 'add events AddHandler dynlabel(intelement).Click, AddressOf check_click If Tool = "Image" Then 'define varibles intelement = intelement + 1 CursorOffset = Windows.Forms.Cursor.Position 'make space ReDim Preserve dynimage(intelement) 'create new label and define propeties Me.Controls.Add(dynimage(intelement)) dynimage(intelement) = New PictureBox dynimage(intelement).Location = New Point((CursorOffset.X - intwidth), (CursorOffset.Y - intheight)) 'add events AddHandler dynimage(intelement).Click, AddressOf check_click End If end sub
Below is what i have in check_click...( not much)
Code:
Public Sub check_click(ByVal sender As Object, ByVal e As EventArgs) 'Sender? If Tool = "Hand" Then ' ADD STUFF HERE YOU DIG ABOUT RESIZING AND MOVING End If end sub
Comment