Saturday 15 June 2013

vb.net - How can a called form get the caller ID or tag of the calling control -


I have a form that is on my form forma called search, when this button is clicked on the frmSearch load I want to make the frmSearch dynamic by calling this button 'search staff' if it's only search for employees etc. Is there a way i can input frmSearch's caller ID or tag instantly?

This is what I have at the moment but it only recognizes the collar control. (I can read this from the illustration of a global variable and frmSearch but there is a better way if I am thinking that):

  private sub btnSearch_Click (as in this object, e EventArgs As btnSearch.Click frmSearch.Show () button as btn dim = CTYPE (sender, button) MsgBox (btn.ToString) MsgBox (& "you clicked the button", CTYPE (CTYPE (sender, _ System.Windows.Forms.Button) .Tag, string, and sub    

forms Your code will look something like this

  private sub Button1_Cli Ck (in the form of this object, in the form of e EventArgs) Handle Button1.Click slow caller string = DirectCast (Sender, Button) .Name as the dim f fm new fmSearch (caller) f.Show () End Sub   

Note that I am not using the default instance of the search form, this is important.

Add this code to the search form <

  in the form of a slow string & lt whoCalled; & lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; Public sub-new (in the form of calling string) InitializeComponent () whoCalled = Calling End Sub   

will include the name of the whoCalled caller variable.

If you want to make the data impossible without making anonymity, then in the search form

  personal sub new () 'This call is required Designer By InitializeComponent () End Sub   

This will force you to use the overloaded constructor.

No comments:

Post a Comment