-1

I'm creating a custom WinForms TextBox control, like this:

class MyTest : TextBox
{
    protected override void OnEnter(EventArgs e)
    {
        this.BackColor = Color.Yellow;
    }
    protected override void OnLeave(EventArgs e)
    {
        this.BackColor = Color.White;
    }
}

When I build the project, I cannot see the control. Can anyone explain why not?

Thanks in advance.

codekaizen
  • 26,990
  • 7
  • 84
  • 140
Gold
  • 60,526
  • 100
  • 215
  • 315

3 Answers3

0

you should add the control inside a project and place it on a form. Just a usercontrol by itself you will not see when you build the project.

Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
0

The control should automatically be displayed and will show up under a tab with the project name. You have to be within a designer view other than your control. If that doesn't work you can right click on the toolbox and click Reset Toolbox. Make sure you are rebuilding the entire solution.

Icono123
  • 3,830
  • 3
  • 21
  • 20
0

You have to make the project containing the custom TextBox a class library. If you however decide to keep it as a single UserControl file in the current project, you'll have to reference the control manually.

Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108