How to write and block the textbox by clicking the button

Asked

Viewed 1,417 times

0

I wanted to know how to write a number in the textbox and block when the button is clicked

 private void button6_Click(object sender, EventArgs e)
 {
        textBox4.Enabled = false;
 }

I managed to make it block, but I could not write inside it, someone explains to me how it does this?

  • Web or Windows Forms?

  • 1

    Windows Forms, sorry we do not clarify

  • Yes, but I’m saying that when you click on the button it blocks and it’s already typed. It’s like you have a default value and you can’t edit

  • That, and also wanted to know how to do for when click the button the textbox appears locked with the default value

1 answer

0


By the code and comments you only need to lock the typing, instead of using Enabled that is very restrictive and disables even use events ReadOnly:

private void button6_Click(object sender, EventArgs e)
{
    textBox4.Text = "Texto Padrão";
    textBox4.ReadOnly = true;
}

To appear when a double click that it is locked for typing, go to the event box and use DoubleClick:

inserir a descrição da imagem aqui

private void textBox4_DoubleClick(object sender, EventArgs e)
{
    MessageBox.Show("Bloqueado !!!");
}

To start the TextBox unseen:

Form_Load

private void Form1_Load(object sender, EventArgs e)
{
     textBox4.Visible = false;
}

or property bank:

inserir a descrição da imagem aqui

  • Friend I think I was perfectly able to do what I wanted using his examples, I only changed Readonly for Enabled = false; to stay the way I wanted, now explain to me how it does so that when the program was opened, the textbox did not appear, And you just show up if you push the button? Thank you.

  • Thank you so much helped me a lot.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.