Results 1 to 4 of 4

Thread: Accessing methods in ControlLibrary

  1. #1

    Thread Starter
    Lively Member Ksyrium's Avatar
    Join Date
    Jun 2004
    Location
    Tennessee..yes, we CAN code!!
    Posts
    80

    Accessing methods in ControlLibrary

    Here's my situation:

    I've created a Control Library which contains one usercontrol which contains a button and three textboxes. I've built the solution and have saved the project.

    In my Windows application I have a reference to my control library and have included the "using..." statement for my control library.

    Now, at runtime I want the ability to drop that usercontrol from my control library and access a method in that class. Make sense????

    I can't seem to access the methods of the UserControl1 class in my control library unless I'm referencing the exact usercontrol on my form.
    VB Code:
    1. private void button8_Click(object sender, System.EventArgs e)
    2.         {
    3.             String tn;
    4.             Control ctl = new Control();
    5.             int x = 1;
    6.             ctl = panel1.GetNextControl(this, true);
    7.             if (ctl is hsControlLibrary.UserControl1)
    8.             {
    9.                 do
    10.                 {
    11.                     ctl.//Cannot access method in UserControl1 class
    12.                     this.BindingContext[dataSet1, "Table1"].Position +=1;
    13.                 }
    14.                 while (panel1.Controls.Count >= x);                                                                        
    15.             }
    16.         }

    Thanks in advance!!!!

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Accessing methods in ControlLibrary

    ctl.//Cannot access method in UserControl1 class
    this.BindingContext[dataSet1, "Table1"].Position +=1;


    Dont you need to cast the object to UserControl1 type?

    e.g (UserControl1)ctl.youProperty
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Lively Member Ksyrium's Avatar
    Join Date
    Jun 2004
    Location
    Tennessee..yes, we CAN code!!
    Posts
    80
    It still won't let me access any class methods at design time.

    If I drop a UserControl1 on my form and reference to it, it works!! But I need to create these at runtime.

    The intellisense only gives me the following:

    hsControlLibrary.UserControl1.ControlAccessibleObject and .ControlCollection. No user defined methods!!!

    But if I drop a UserControl1 on my form then go..

    this.myUC.BindControls(...); //I get my method!!!

    ????

  4. #4

    Thread Starter
    Lively Member Ksyrium's Avatar
    Join Date
    Jun 2004
    Location
    Tennessee..yes, we CAN code!!
    Posts
    80

    [RESOLVED]

    I figured this out.

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