How can i find type sender object?

  • Thread starter Thread starter nomenklatura
  • Start date Start date
N

nomenklatura

Hi,
i call
Call treeviewXi_DoubleClick("Try", e)

from another procedur..

and in treeviewX_DoubleClick i use this string and do what i want

example : if sender="try" then doit

but in this case, when user do doubleclick, in treeview doubleclick event,
sender object is turn treeview object and give error due to "if sender="try"
then doit" row

i wantto this:

Private Sub treeviewwX_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles trwErisimAgaci.DoubleClick

dim x as string

if istypefunction(sender)=string then

x=sender

else

x=treeviewX.SelectedNode.Tag

endif

How?

Thanks in advance,
 
nomenklatura,
if istypefunction(sender)=string then

I would use the "TypeOf ... Is" operator to find the type of sender.

If TypeOf sender Is String Then


However! This seems like very bad & fragile code!

Remember that Sender is the control that raised the event, NOT a string!!!

I would create a new routine that accepted a string, the
treeviewXi_DoubleClick event handler would call this new routine with
treeviewX.SelectedNode.Tag, while every place else would call the routine
with the specific string value.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top