Gustavo

Gustavo

  • NA
  • 1.3k
  • 449.3k

How Do I: Get rid of redundant code? (Put in a userControl?) Part 2:

Apr 1 2010 12:13 PM

Hello:
 
I have tried for two days now. I still can not get it to work. I have the following code that I have in every form. I would like to put it in one place and include it in all my forms. Like the C+ with the #include. Can someone give me a sample of how I can do it?
 
 
 
public FormICEPack()
{
InitializeComponent();
Control TheControl = GetNextControl(null, true);
while (TheControl != null)
{
if (TheControl.GetType().Name == "TextBox")
{
TheControl.Enter +=
new EventHandler(Object_Enter);
TheControl.Leave +=
new EventHandler(Object_Leave);
//TheControl.Click += new EventHandler(Object_Click);
TheControl.MouseHover +=
new EventHandler(textBox_MouseHover);
TheControl.MouseLeave +=
new EventHandler(textBox_MouseLeave);
}
TheControl = GetNextControl(TheControl,
true);
}
}

Answers (10)