S
shuiwen
Unregistered / Unconfirmed
GUEST, unregistred user!
自定义LISTBOX,设置成自画,并在
procedure TNewListBox.DrawItem(Index: Integer; Rect: TRect;
State: TOwnerDrawState);
Begin
inherited;
if (index=FitemIndexBold)Then
begin
with Canvas do
begin
// FillRect(Rect);
// Font.Size := 10;
// Font.Name := '宋体';
Font.Color := Clred;
Font.Style:=[fsBold];
end;
Canvas.TextOut(Rect.Left+1, Rect.Top+1,Items[Index]);
end
else
begin
with CanVas do
begin
Font.Color:=clWindowText;
Font.Style:=[];
Canvas.TextOut(Rect.Left+1, Rect.Top+1,Items[Index]);
end;
end;
procedure TNewListBox.SetItemIndexBold(Index:Integer);
Begin
FitemIndexBold:=Index;
Invalidate;
end;
当设置一行变色,没问题,但设置多行,就不行,如何写GetItemIndex函数?不要告诉是FitemIndexBold这样不行,多行设置如何控制??
procedure TNewListBox.DrawItem(Index: Integer; Rect: TRect;
State: TOwnerDrawState);
Begin
inherited;
if (index=FitemIndexBold)Then
begin
with Canvas do
begin
// FillRect(Rect);
// Font.Size := 10;
// Font.Name := '宋体';
Font.Color := Clred;
Font.Style:=[fsBold];
end;
Canvas.TextOut(Rect.Left+1, Rect.Top+1,Items[Index]);
end
else
begin
with CanVas do
begin
Font.Color:=clWindowText;
Font.Style:=[];
Canvas.TextOut(Rect.Left+1, Rect.Top+1,Items[Index]);
end;
end;
procedure TNewListBox.SetItemIndexBold(Index:Integer);
Begin
FitemIndexBold:=Index;
Invalidate;
end;
当设置一行变色,没问题,但设置多行,就不行,如何写GetItemIndex函数?不要告诉是FitemIndexBold这样不行,多行设置如何控制??