How to inhibit textbox but display ID data

Asked

Viewed 53 times

1

I would like the Textbox ID to be inhibited (I don’t want to be invisible) but to display ID data that is saved (autoincrement) in the database.

I’m using Visual Studio 2015 Community.

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

1 answer

3


Changing the property Enabled for false, or the property ReadOnly for true.

In most components, change the value of ReadOnly keeps the control with the same appearance, but prevents some value from being inserted. In contrast, the Enabled shows the control with a slightly different appearance. But this at all times will vary as 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.

Form com três textboxes

You can do this in the code, in the form builder

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

Or in the properties window, by Visual Studio.

  • Addendum: In the case of TextBox, with the ReadOnly it gets a darker background color (which can be changed). Basically the difference between the two properties is that the ReadOnly still allows the Focus in control, and the Enabled nay.

  • It worked perfectly. Thank you very much

  • @Fabioaragão I don’t know if you know, but whenever an answer solve your problem you can mark it as correct using the V on the left side.

  • @LINQ I believe I’ve done it before..

  • @Fabioaragão Not yet, because you have to wait 15 minutes of question to be able to score.

  • @LINQ got it.. I dialed the answer... helped me a lot here. thanks

Show 1 more comment

Browser other questions tagged

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