Question

Objective: I'm trying to make the first 3 items on a TCheckListBox control appear in bold. lstMenuPermissions is my control.

So I tried this:

procedure TfrmPermissions.lstMenuPermissionsDrawItem(Control: TWinControl;
  Index: Integer; ARect: TRect; State: TOwnerDrawState);
begin      
  if index < 3 Then 
    with (Control as TCheckListBox).Canvas do
      begin
        Font.Bold := True;           
        TextOut(ARect.Left, ARect.Top, (Control as TCheckListBox).Items[Index]);
      end;

end;  

There was no effect so I thought of checking if the event got fired in the first place and I tried this:

procedure TfrmPermissions.lstMenuPermissionsDrawItem(Control: TWinControl;
  Index: Integer; ARect: TRect; State: TOwnerDrawState);
begin
  ShowMessage('OK');
end;  

I have also set the Style to lbOwnerDrawFixed.

But there is no message box. So I'm guessing that the event is not firing. Maybe I'm doing something wrong. Please advise on how I should get about this.

Thanks!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top