Nazgulled Posted July 16, 2007 Posted July 16, 2007 Hi, I have the following code I got from divil (Introduction to Designers): [csharp]using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; using System.ComponentModel.Design; using System.Windows.Forms.Design; namespace CSharpTest { [Designer(typeof(MyControlDesigner))] public class UserControl1 : UserControl { public Button button1 = new Button(); public void TestMethod() { } } internal class MyControlDesigner : ControlDesigner { public override DesignerVerbCollection Verbs { get { DesignerVerbCollection v = new DesignerVerbCollection(); v.Add(new DesignerVerb("Sample Verb", new EventHandler(SampleVerbHandler))); return v; } } private void SampleVerbHandler(object sender, System.EventArgs e) { // CODE GOES HERE } } }[/csharp] This codes places a task link in my subclassed usercontrol that I have placed on a form: http://stuff.nazgulled.net/images/designerverb.jpg I need to know how can I acces the controls/methods in the UserControl1 class inside the SampleVerbHandler(). Is this possible, how? Quote
Nazgulled Posted July 16, 2007 Author Posted July 16, 2007 Solved: [csharp]private void SampleVerbHandler(object sender, System.EventArgs e) { UserControl1 myControl = this.Control as UserControl1; if (myControl != null) { // DO WORK HERE } }[/csharp] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.