>public class YesNoBox : TextBox > > { > > private Char spaceChar; > > > > public YesNoBox() > > { > > this.spaceChar = Convert.ToChar(" "); > > this.Tag = "TRUE"; > > this.KeyPress += new KeyPressEventHandler(YesNoBox_KeyPress); > > } > > > > void YesNoBox_KeyPress(object sender, KeyPressEventArgs e) > > { > > if (e.KeyChar == spaceChar) > > { > > ToggleDisplay(); > > } > > else if (e.KeyChar == 'N' || e.KeyChar == 'n') > > { > > base.Tag = "FALSE"; > > base.Text = "N"; > > } > > else if (e.KeyChar == 'Y' || e.KeyChar == 'y') > > { > > base.Tag = "TRUE"; > > base.Text = "Y"; > > } > > e.Handled = true; > > } > > > > private void ToggleDisplay() > > { > > switch (this.Tag.ToString()) > > { > > case "TRUE": > > base.Tag = "FALSE"; > > base.Text = "N"; > > break; > > case "FALSE": > > base.Tag = "TRUE"; > > base.Text = "Y"; > > break; > > default: > > base.Tag = "ERROR"; > > base.Text = "ERROR"; > > break; > > } > > } > > } >