Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the main difference between ReadOnly and Enabled?

In Windows Forms controls, there are two properties: ReadOnly and Enabled.

What is the difference between these two properties? I feel like they behave the same way.

like image 783
Diskdrive Avatar asked Jun 21 '10 23:06

Diskdrive


People also ask

What is the difference between the readonly and disabled?

The difference between disabled and readonly is that read-only controls can still function and are still focusable, whereas disabled controls can not receive focus and are not submitted with the form and generally do not function as controls until they are enabled.

What is the difference between the readonly?

Difference between const and readonly const fields has to be initialized while declaration only, while readonly fields can be initialized at declaration or in the constructor. const variables can declared in methods ,while readonly fields cannot be declared in methods.

What is the difference between the randomly and disabled attributes?

The difference between the two has to do with how the parent form views each field. When a textarea is disabled , it will be ignored by a parent form. However, when a textarea is readonly the contents of the textarea will still be submitted with the form even though the user cannot modify the contents.

What is readonly in asp net?

Use the ReadOnly property to specify whether the contents of the TextBox control can be changed. Setting this property to true will prevent users from entering a value or changing the existing value. Note that the user of the TextBox control cannot change this property; only the developer can.


2 Answers

As it says in the following forum post:

In the context of a TextBox, readonly allows the user to set focus to and select and copy the text but not modify it. A disabled TextBox does not allow any interaction whatsoever.

Use ReadOnly when you have data that you want the user to see and copy, but not modify. Use a disabled textbox, when the data you are displaying is not applicable in for the current state of a dialog or window.

Taken from: MSDN Forums

like image 175
Jamie Keeling Avatar answered Oct 11 '22 17:10

Jamie Keeling


ReadOnly I generally associate with a TextBox or other control that contains text; it dictates whether or not the user can modify the text displayed by the control. The user can still select the text, though (e.g., to copy and paste it into another program).

Enabled basically controls whether or not any user interaction with the control is possible. For instance a Button with Enabled == false cannot be clicked; a CheckBox with Enabled == false cannot be toggled, etc. Note that a TextBox with Enabled == false also cannot have its text selected (that would be user interaction).

Furthermore, controls with Enabled == false do not raise events related to user interaction such as Click.

like image 42
Dan Tao Avatar answered Oct 11 '22 15:10

Dan Tao