Mason Wheeler wrote:
> I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox. One of the things I want to change is the Options property's defaults. TCustomDBGrid defines Options as:
> property Options: TDBGridOptions read FOptions write SetOptions
> default [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit];
> Trying to override that in my class with
> property Options: TDBGridOptions default
> [dgTitles, dgTabs, dgRowSelect, dgAlwaysShowSelection, dgCancelOnExit];
That merely changes the value that the IDE treats as the one it doesn't
need to bother storing to the DFM when it saves the form and its
components. It has absolutely no effect at run time, and it does not
change the value of any property.
> doesn't work; the compiler expects *read* or *write* after the type, not *default*.
Try removing the type.
property Options default ...;
> Problem is, FOptions and SetOptions are both defined as private, not protected, in TCustomDBGrid.
> Do I have to write my own get and set methods that invoke "*inherited* Options", or is there a simpler way?
Since you haven't actually changed what the initial value will be for
that property, you'll still need to write some code. Do it in the
Options := NewDefaultOptions;
Any forms that were using the old set of default options will get the
new set the next time the form is loaded (at design time or run time).
This is because the Options property was never saved for that form
anyway, due to the "default" directive on the original property declaration.