I am using these following code. I want to when I select all text in the textbox it tells me but I don’t know why it’s not working. please give me some help. Please give some code so that I can use this when I select all text in the textbox text it tells me
if (textBox1.SelectAll() == true)
{
MessageBox.Show("You have selected all text in the textbox");
}
It will tell me: Operator == cannot be applied to operands of type void and bool
Couldn’t you simply check whether or not
TextBox.SelectionLength == TextBox.Text.Length?http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectionlength.aspx
You comparison fails because you’re comparing the text with the return value of the
SelectAllmethod which is void(it returns nothing since it just applies the selection).