Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

Solved:

 

[csharp]private void SampleVerbHandler(object sender, System.EventArgs e) {

UserControl1 myControl = this.Control as UserControl1;

if (myControl != null) {

// DO WORK HERE

}

}[/csharp]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...