Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TAdvSmoothListBox
Customizing the ItemAppearance

The appearance of the TAdvSmoothListBox and its items can be fully customized.

Following code:

procedure TForm1.AdvSmoothListBox1ItemBkgDraw(Sender: TObject;
  Canvas: TCanvas; itemindex: Integer; itemRect: TRect;
  var defaultdraw: Boolean);
var
  g: TGPGraphics;
begin
  defaultdraw := AdvSmoothListBox1.SelectedItemIndex <> itemindex;
  if not defaultdraw then
  begin
    g := TGPGraphics.Create(Canvas.Handle);
    g.SetSmoothingMode(SmoothingModeAntiAlias);
    AdvSmoothListBox1.ItemAppearance.FillSelected.Fill(g, MakeRect(itemrect.Left, itemrect.Top, itemrect.Width, itemrect.Height));
    g.Free;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  it: TAdvSmoothListBoxItem;
  I: Integer;
begin
  AdvSmoothListBox1.BeginUpdate;
  AdvSmoothListBox1.Fill.Color := clBlack;
  AdvSmoothListBox1.ItemAppearance.Fill.Color := clBlack;
  AdvSmoothListBox1.ItemAppearance.Fill.ColorMirror := clNone;
  AdvSmoothListBox1.ItemAppearance.Fill.BorderColor := clBlack;
  AdvSmoothListBox1.ItemAppearance.Fill.GradientType := gtSolid;
  AdvSmoothListBox1.ItemAppearance.Fill.GradientMirrorType := gtNone;
  AdvSmoothListBox1.Header.Visible := False;
  AdvSmoothListBox1.Footer.Visible := False;
  AdvSmoothListBox1.Sections.BorderColor := AdvSmoothListBox1.ItemAppearance.Fill.Color;
  AdvSmoothListBox1.ItemAppearance.FillSelected.Assign(AdvSmoothListBox1.ItemAppearance.Fill);
  AdvSmoothListBox1.ItemAppearance.FillSelected.Color := clWebOrange;
  AdvSmoothListBox1.ItemAppearance.FillSelected.Rounding := 10;
  AdvSmoothListBox1.ItemAppearance.FillSelected.RoundingType := rtBoth;
  AdvSmoothListBox1.DefaultItem.CaptionFont.Color := clWhite;
  AdvSmoothListBox1.Items.Clear;
  for I := 0 to 19 do
  begin
    it := AdvSmoothListBox1.Items.Add;
    it.Caption := ''Item '' + inttostr(I + 1);
  end;
  AdvSmoothListBox1.EndUpdate;
end;

Results in: