CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006
    Posts
    99

    Resolved [SOLVED]another embarsassing ?

    i have a user control

    defined an interface on it
    Code:
      public interface IMain
            {
                [DispId(1)]
                int addsomething(int val1,int val2)
            }
    
    public class Main : IMain
            {
                public Main() { }
                public int addsomething(int val1,int val2)
                {
                    return(val1 + val2)
                }
    
    }
    the conntrol builds.

    now i place the control on my form/page. how do i get to the interfaces???
    i know this is really simple but need to ask...as this is one of the rare times i work on wb controls...or windows controls...

    [Resolution]
    1. compiled my user control. it is called myusercontrol.dll
    2. created new windows application in c#
    3. loaded myusercontrol and its instance is called testingmyusercontrol
    4. declared the following
    public myusercontrol.usercotrol.IMain interfaceTest;

    5. button on click event:
    set interfacetest = new myusercontrol.usercontrol.main();
    int result = interfacetest.addsomething(1,1)


    BlackLazy: where would the 'code' button be? yea i now know that one can use the tags
    Last edited by jss3426; February 19th, 2007 at 08:56 PM. Reason: [SOLVED]

  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: another embarsassing ?

    Did you try...

    IMain mainInterface = myusercontrolvariable as IMain; ???

  3. #3
    Join Date
    Nov 2006
    Posts
    99

    Re: another embarsassing ?

    poochi,
    i did thitrying it on a windows app now

    contrl = wincontrl
    contrl name on form = mytestctrl [instance of wincontrl]

    wincontrl.usercontrol.IMain iFaceTest = (wincontrl.usercontrl.Imain)mytestctrl;

    of course this results in an error...

  4. #4
    Join Date
    Dec 2006
    Location
    Wisconsin
    Posts
    93

    Re: another embarsassing ?

    Join the fight, refuse to respond to posts that contain code outside of [ code ] tags
    Kenneth Jones, .Net Framework BCL/CLR Guru
    Join the fight, refuse to respond to posts that contain code outside of [ code ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured