Subject Re: [IBO] fields read-only in a TIB_Grid
Author Helen Borrie (TeamIBO)
At 12:59 PM 18-02-02 +0100, you wrote:
>it seems that when I declare a field as read-only in a TIB_Query (using the
>FieldsReadOnly list), they become not only "not editable", but they cannot
>be changed in any way.
>
>I'd like to prevent the user from changing some fields, but I still want to
>be able to change them programmatically, if needed.
>
>Ok, I can play with the OnKeyPress event of the grid and abort when the
>user tries to write in one of those fields.
>
>But as a result I lose the nice gray color that take the read-only fields
>in a grid.
>
>Ok, I can also play with the OnDraw event of the grid etc etc.
>
>But should one suffer so much to get such a little thing ?
>
>Is there no other way ?

Yes, there is the RIGHT way. Set READONLY to T(rue) only if you want the column to be read-only to the application as a whole. To prevent the user from editing, inserting or searching in the column, use the NOEDIT and/or NOINSERT and/or NOSEARCH attributes as required and set READONLY true or false as required.

e.g. (from the IBO Component help - TIB_Statement.FieldsReadOnly -

[< tablename >.]< columnname >=T[RUE];NOEDIT;NOINSERT;NOSEARCH
[< tablename >.]< columnname >=F[ALSE];NOEDIT;NOINSERT;NOSEARCH

The reason for the [ ] in these examples is that you can set these attributes globally in the connection object and you need to use table identifiers there.


regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at www.ibobjects.com