zozo mehr

zozo mehr

  • NA
  • 5
  • 4.5k

make an event for cleaning a textbox

Feb 19 2013 12:08 PM

hello

i made a class that  inherite from text box.

i have a Textbox that receives a button as Clean button. then a function is added to this button's events.

this function clean content of textbox.

but my code dose'nt work.

public partial class MyTxt : TextBox
{

public MyTxt()

{

InitializeComponent();

}public MyTxt(IContainer container)

{

container.Add

this);

InitializeComponent();

CleanButton =

new Button();

CleanButton.Click +=new EventHandler(CleanTxt);
}

public void CleanTxt(object sender, EventArgs e)

{

this.Text = "";

}

private Button _CleanButton ;

public Button CleanButton

{

get { return _CleanButton; }

set { _CleanButton = value; }

}

}


   


Answers (2)