Jump to content


Photo

TnxComboBox - items with different colors


  • Please log in to reply
5 replies to this topic

#1 PCBleu

PCBleu
  • Members
  • 33 posts

Posted 28 July 2014 - 05:00 PM

Hey

I just want to build a combo box with different items having different colors

for example different values with colors blue, orange, red

Thanks for any example in Delphi 7

#2 PCBleu

PCBleu
  • Members
  • 33 posts

Posted 29 July 2014 - 04:25 PM

Hey - I tried onDrawItem event, but it seems to be not available for NxComboBox controls !!!

with this code :
procedure TForm1.NxComboBox1DrawItem(Sender: TObject; Index: Integer; Rect: TRect; State: TNxItemState);
begin
  if index mod 2<>1 then begin
    nxComboBox1.canvas.brush.color:=clwhite;
    nxComboBox1.canvas.fillrect(rect);
  end
  else begin
    nxComboBox1.canvas.brush.color:=$00F4F3EE;
    nxComboBox1.canvas.fillrect(rect);
  end;
  nxComboBox1.canvas.textout(rect.left+30,rect.top+2,ComboBox1.items[index]);
end;


#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 30 July 2014 - 08:50 PM

Hi,

Please tell me do you also have set DrawingOptions property of ComboBox?
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 PCBleu

PCBleu
  • Members
  • 33 posts

Posted 30 July 2014 - 10:34 PM

Hey

with any option of DrawingOptions, I do not obtain what I expect

Thanks for your help

Here is an example of what I want to obtain

Posted Image

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 31 July 2014 - 01:15 PM

Hi,

I forgot to mention, that you need to access to the Canvas of PopupControl, not combobox itself:

  with NxComboBox1.PopupControl.Canvas do
  begin
    Brush.Color := clRed;
    FillRect(Rect);
  end;

I hope that this helps.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 PCBleu

PCBleu
  • Members
  • 33 posts

Posted 31 July 2014 - 03:31 PM

Thanks a lot - That helps




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users