Skip to Content
author's profile photo Former Member
Former Member

change the BackColor of an EditText

how to change the BackColor of an EditText ? and persist the new color if the EditText gets Focus

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 11:58 AM

    Hello.

    I think You can do it right this:

    on the event et_Got_Focus you can change background: (C++)

    if (pVal->EventType==et_GOT_FOCUS && pVal->ItemUID==L"ID")
    {
    SAPbouiCOM::IEditTextPtr edit;
    edit = m_pForm->Items->Item("ID")->Specific;
    edit->PutBackColor(RGB(REDNUMBER,GREENNUMBER,BLUENUMBER));
    
    }
    else if (pVal->EventType==et_LOST_FOCUS && pVal->ItemUID==L"ID")
    {
    SAPbouiCOM::IEditTextPtr edit;
    edit = m_pForm->Items->Item("ID")->Specific;
    edit->PutBackColor(RGB(255,255,255));
    }
    

    I think that should work.

    Hope it helps.

    Regards

    Kamil Wydra

    Message was edited by: Kamil Wydra

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 12:09 PM

    Hi Ketan,

    this works on 2005A SP01 PL04:

    f.Items.Item("10").BackColor = 0x00ff0000; // Blue

    where f is an instance of a Deliveries form.

    To get what you want you should set the background when you catch the GOT_FOCUS event on the control, then restore the old background on LOST_FOCUS.

    Hope this helps

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Yellow background is the field highlight of B1, you cannot change it.

      You could highlight your data field in other ways, such as changing the label color when it got the focus. I'm using this technique and it works fine.

      Hope this helps

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 03:18 PM

    OK,USE THIS METHOD ,I CAN DO IT

    Add comment
    10|10000 characters needed characters exceeded