Mirror

Disabling a TMemo without getting gray text (Views: 101)


Problem/Question/Abstract:

I want to set Enabled=False in my TMemo, but I don't want the text to turn gray.

Answer:

OPTION 1:

Ok, this is a dirty trick. But is works fine for me.

Set the Enabled to True (yes realy).
In the OnEnter event of your memo put:

procedure TForm1.MyMemoEnter(Sender: TObject);
begin
  SomeOtherControl.SetFocus;
end;

Now, focus will be forced to some other control every time your user tries to fucus on your memo. To the user it seems that the memo is disabled.

OPTION 2:

This one is much simpler:
Put the memo on a panel. Then set Panel.Enabled=False.
Ok, this works if you can put the memo on a panel. Just with inherited forms you can get into some trouble. But is should work for most people.

<< Back to main page