在checklistbox的DrawItem事件中加入以下代码。 设置checklistbox的style为lbOwnerDrawFixed。 with (Control as TCheckListBox).Canvas do { draw on control canvas, not on the form } begin FillRect(Rect); { clear the rectangle } if ((Control as TCheckListBox).Checked[Index]) then Font.Color := clRed else Font.Color := clblue; TextOut(Rect.Left , Rect.Top, (Control as TCheckListBox).Items[Index]) { display the text } end;
我提供一个:http://www.ironwareinfo.com.cn/breeze/delphi/Components.asp
设置checklistbox的style为lbOwnerDrawFixed。 with (Control as TCheckListBox).Canvas do { draw on control canvas, not on the form }
begin
FillRect(Rect); { clear the rectangle }
if ((Control as TCheckListBox).Checked[Index]) then
Font.Color := clRed
else
Font.Color := clblue; TextOut(Rect.Left , Rect.Top, (Control as TCheckListBox).Items[Index]) { display the text }
end;