- This topic has 2 replies, 3 voices, and was last updated 13 years, 4 months ago by Support.
-
AuthorPosts
-
July 4, 2011 at 4:43 am #34650azrael11Participant
Can i change the style of the each line in sCheckListBox…
Example
Line1 = Paris [Font Style:= Bold, Size:= 10]
Line2 = London [Font Style:= Regular, Size:= 8]
……
Thank you….
July 4, 2011 at 8:43 pm #46158IPStevenParticipantYou need to use the DrawItem event.
In the code below I'm using a list box to contain names of the fonts I want and the code cycles through the list.
Code:procedure TForm1.sCheckListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
i : Integer;
begin
i := Index;
if Index >= (sListBox1.Count – 1) then
i := Index mod sListBox1.Count;with sCheckListBox1.Canvas do
begin
FillRect(Rect);
Font.Name := sListBox1.Items;
Font.Size := 0; // use font's preferred size
TextOut(Rect.Left+1, Rect.Top+1, sCheckListBox1.Items[index]);//if you don't know what to set the itemheight as
//since MeasureItem() property doesn't work – you can use this, its ugly but does the job
i := TextHeight('Wgyj') + 2; // measure ascenders and descenders
if sCheckListBox1.ItemHeight < i then
sCheckListBox1.ItemHeight := i;
end;
end;I haven't messed with changing the font properties (Bold, Italic, etc.) and don't know if its as simple as adding
Code:Font.Style := [fsBold];or not.
I don't know if it is bug in AlphaSkins or not but the MeasureItem() event in sCheckListBox is not firing.
With a regular list box you could use this event to individually adjust the height of each line as needed.
Serge – if your checking out this thread maybe you could comment or check it out?
**Edit – added attachment and image**
I've attached a sample project demo below.
[attachment=4970:CheckListBoxDynamicFonts.png]
[attachment=4969:CheckListBoxDynamicFonts.rar]
BTW if you want to change the background colors in the CheckListBox check out:
http://delphi.about.com/cs/adptips2002/a/bltip0602_4.htm
…Steven
July 7, 2011 at 10:13 am #46173SupportKeymaster'IPSteven' wrote:I don't know if it is bug in AlphaSkins or not but the MeasureItem() event in sCheckListBox is not firing.With a regular list box you could use this event to individually adjust the height of each line as needed.
Serge – if your checking out this thread maybe you could comment or check it out?
Hello
Try change the style property to lbOwnerDrawVariable.
-
AuthorPosts
- You must be logged in to reply to this topic.