Add the following event-handler in the constructor:
textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
Event:
void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar.Equals('0')) || (e.KeyChar.Equals('1')))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}