How to inhibit textbox but display ID data

1

I would like the TextBox ID to be inhibited (I do not want to be invisible) but to display ID data that is autoincrement in the database.

I'm using Visual Studio 2015 Community.

Example: I register a client without putting the ID, but when I was viewing this client, the ID would be displayed in the textox ID.

    
asked by anonymous 05.02.2018 / 18:10

1 answer

3

Changing property Enabled to false , or property ReadOnly to true .

On most components, changing the value of ReadOnly keeps the control looking the same, but prevents some value from being inserted. In contrast, Enabled shows the control with a slightly different look. But this always will vary depending on the operating system, in the form below the first TextBox is normal, the second is with Enabled as false and the third is with ReadOnly active. >

You can do this in the code in the form constructor

public MeuForm()
{
    InitializeComponents();
    txtId.Enabled = false;
}

Or in the properties window, through Visual Studio.

    
05.02.2018 / 18:13