Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Color Property For TEdit
Sat, Oct 10 2015 12:57 AMPermanent Link

Frederick Chin

Is it possible for me to create a custom version of TEdit where there is a property for color? I would like the Color property to change if there is a problem with the data entered.

Frederick
Sat, Oct 10 2015 4:37 AMPermanent Link

Matthew Jones

<Frederick Chin> wrote:
> Is it possible for me to create a custom version of TEdit where there is
> a property for color? I would like the Color property to change if there
> is a problem with the data entered.
>

Very nice idea.

--
Matthew Jones
Sat, Oct 10 2015 6:18 AMPermanent Link

Christian Kaufmann

Frederick Chin wrote:

> Is it possible for me to create a custom version of TEdit where there is a property for color? I
> would like the Color property to change if there is a problem with the data entered.

The TEdit already has an "error" state in the interface and a Boolean property you can change.

cu Christian
Sat, Oct 10 2015 10:18 AMPermanent Link

Frederick Chin

"Christian Kaufmann" wrote:

/*
The TEdit already has an "error" state in the interface and a Boolean property you can change.
*/

I didn't know that but how do I change the color of the TEdit control or create a custom control with the color property.

I have seen a web site where the edit box's color changes to red if the data entered is incorrect. It is visually obvious that an error has occurred.

Frederick
Sat, Oct 10 2015 11:35 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/10/2015 10:18 AM, Frederick Chin wrote:
> I didn't know that but how do I change the color of the TEdit control or create a custom control with the color property.

Easiest is to just modify the interface (2nd last icon on the form
design toolbar) - you need to make a a copy of the interface file
(tedit.wbi) in this case and then you can change background/colors etc
for all the relevant states.

> I have seen a web site where the edit box's color changes to red if the data entered is incorrect. It is visually obvious that an error has occurred.

That's exactly what the error state does already - it sets the edit box
border to red.

Try it out - simple example might be something like :

if MyEdit.Text='' then
  MyEdit.Error := true
else
  MyEdit.Error := false


If you need more than just border in red then modify the interface.

Raul
Sat, Oct 10 2015 11:32 PMPermanent Link

Frederick Chin

Raul,

/*
Easiest is to just modify the interface (2nd last icon on the form
design toolbar) - you need to make a a copy of the interface file
(tedit.wbi) in this case and then you can change background/colors etc
for all the relevant states.
*/

/*
That's exactly what the error state does already - it sets the edit box
border to red.

Try it out - simple example might be something like :

if MyEdit.Text='' then
  MyEdit.Error := true
else
  MyEdit.Error := false

If you need more than just border in red then modify the interface.
*/

Thanks. I'll explore both options and see which is the best for my scenarios.

Frederick
Mon, Oct 12 2015 3:39 AMPermanent Link

Matthew Jones

Christian Kaufmann wrote:

> The TEdit already has an "error" state in the interface and a Boolean
> property you can change.

I had a quick look at this, and it would be really nice to have this
surfaced as an editable property in the IDE. I think it would be more
discoverable that way, and also allow visual testing etc.

--

Matthew Jones
Image