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.