Ian
There are no individual checkbox controls in the list, they are all fakes.
The checklistbox is a owner-drawn listbox internally, unfortunately coded in
a way that makes changing the way it draws somewhat difficult. Here is a
little project that shows how to change the text background color depending
on the items state. It has one major drawback: the checkbox is not drawn on
the selected color but always on the controls Color as background. The only
way to modify the drawing of the checkbox would be to completely draw it
yourself, basically copying the DrawCheck method from TCheckListbox.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CheckLst;
type
TCheckListBox = Class( CheckLst.TCheckListbox )
protected
Procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
override;
end;
TForm1 = class(TForm)
CheckListBox1: TCheckListBox;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TCheckListBox }
procedure TCheckListBox.DrawItem(Index: Integer; Rect: TRect;
State: TOwnerDrawState);
begin
If not (odSelected In State) Then
If Checked[ Index ] Then
Canvas.Brush.Color := clLime
Else
Canvas.Brush.Color := clYellow;
inherited;
end;
end.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!