Delphi - ReadOnly Components

In some applications, I use ReadOnly components to display data that the user is not allowed to modify. In other applications, the state of the component depends on various factors.

In general, many components provide a ReadOnly property ... however, in other cases there is no obvious solution.


Components with a "ReadOnly" Property

Most components based on TCustomEdit will have a ReadOnly property ... including This is sample code I use to change the ReadOnly status of these components


TComboBox

TComboBox does NOT have a ReadOnly property ... therefore, you will have to fake it.

These commands call the Windows api directly. They will keep a user from typing a new value, but not from selecting a new value from the list.

You could set Enabled false, but then This kludge works Experiments using - Style := csDropDownList - did not work - it hid the list and stopped the user from typing ... but the other list options could still be selected using the arrow keys.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / Delphi / ReadOnly.html