I'm using C#/.NET for a Windows Forms application. I have a text box. How can I make the text box unselectable?
I don't want to disable the complete textbox.
Set textBox. Enabled = false to prevent selection (see here).
You can try using: textBox. ReadOnly = true; textBox.
Set the TextBox control's ReadOnly property to true . With the property set to true , users can still scroll and highlight text in a text box without allowing changes.
In the 'Enter' event of the textbox set the ActiveControl to something else:
private void txtMyTextbox_Enter(object sender, EventArgs e)
{
ActiveControl = objMyOtherControl;
}
You have a couple of options:
Label
control instead.textBox.Enabled = false
to prevent selection (see here).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With