doesnt show up in the dropdown list as a useable method (post for brian)

Working on an unrelated program, but this kinda falls into a related topic.

I have 2 forms in this example, form_main and form_abilities. When you hit a button, form_main is hidden, and a new instance of form_abilities is created/shown with form_main as the owner. form_main has a method like the following:

public void ability_close(int a, int b, int c, int d, int e, int f)
{
//some irrelevent code here
}

when inside form_abilities, I've tryed to use:

get_Owner().ability_close(a,b,c,d,e,f);

but it doesnt show up in the dropdown list as a useable method, and if I manually type it in I get a "Cannont find method" error. What am I missing/need to do to get this working




Answer this question

doesnt show up in the dropdown list as a useable method (post for brian)

  • confuced!

    Hi,

    get_Owner() returns an instance of System.Windows.Forms.Form. System.Windows.Forms.Form is the parent class of all windows forms in .net including form_main.

    Since get_Owner() returns a handle to the parent class, you need to typecast the return type to the derived class and then only you can access the members of the derived class. Please check below code...

    form_main owner = (form_main)this.get_Owner();

    owner.ability_close(1, 1, 1, 1, 1, 1);

    And this is not specific to intellisense. If you don't typecast properly then compiler will also give errors.

    Above code compiles fine for me and i am able to see all members in the intellisense drop down. Please revert if you have any issues.

    Thanks.



  • Poney

    thank you sooo much!
  • doesnt show up in the dropdown list as a useable method (post for brian)