Adding an editable field to a non-editable form
Have you ever needed to make a form uneditable rather than just one field? This recipe will show you a quick and easy way to do it.
Getting ready
Create a list form based on the Customer table that displays the number and name of the customer. The Editable
property of the form should be set to No.
How to do it...
View the code for the Name column in the list form.
In the
OnActivate
trigger, add the following code:CurrForm.EDITABLE := TRUE;
In the
OnDeactivate
trigger add the following code:CurrForm.EDITABLE := FALSE;
Save and close the form.
How it works...
When you click on a textbox its OnActivate
trigger is executed. In our form, we have told the system to override the default Editable
property when we click on the textbox. We set it to true so that the field becomes editable. In fact, the entire form becomes editable. We must make the entire form editable because that overrides the editable property of the controls on the form.
But when we...