Recent

Author Topic: [SOLVED] TDBLookupCombobox  (Read 457 times)

madref

  • Hero Member
  • *****
  • Posts: 743
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
[SOLVED] TDBLookupCombobox
« on: January 29, 2020, 01:41:14 pm »
With a ComboBox you can do this:

Code: Pascal  [Select]
  1. procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;  ARect: TRect; State: TOwnerDrawState);
  2. begin
  3. ComboBox1.Canvas.FillRect(ARect);                                         //first paint normal background
  4. ComboBox1.Canvas.TextRect(ARect, 20, ARect.Top, ComboBox1.Items[Index]);  //paint item text
  5. ImageList1.Draw(ComboBox1.Canvas, ARect.Left + 1, ARect.Top + 1, Index);  //draw image according to index on canvas
  6. end;
Source: Wiki
sou
Is this also possible for a TDBLookupCombobox?
Is yes how?
« Last Edit: February 01, 2020, 11:44:14 am by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.6 / FPC 3.0.4
Lazarus Trunc / FPC Trunc
Mac OS X Mojave

madref

  • Hero Member
  • *****
  • Posts: 743
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: TDBLookupCombobox
« Reply #1 on: January 31, 2020, 07:06:29 pm »
Anyone?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.6 / FPC 3.0.4
Lazarus Trunc / FPC Trunc
Mac OS X Mojave

howardpc

  • Hero Member
  • *****
  • Posts: 3310
Re: TDBLookupCombobox
« Reply #2 on: January 31, 2020, 08:37:28 pm »
sou
Is this also possible for a TDBLookupCombobox?
I don't see why not, since TDBLookupComboBox has a Style property and an OnDrawItem event.
Quote
If yes how?
Adapt the code you showed to the case of a DBLookup, according to whatever you want to custom draw.

madref

  • Hero Member
  • *****
  • Posts: 743
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: TDBLookupCombobox
« Reply #3 on: February 01, 2020, 11:43:51 am »
Pfff.... stupid me....


I had forgotten to do this...
Code: Text  [Select]
  1. Change from ComboBox1 in the Object Inspector the property Style to csOwnerDrawFixed.
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.6 / FPC 3.0.4
Lazarus Trunc / FPC Trunc
Mac OS X Mojave