Team OO Software Development

Friday, April 07, 2006

GUI Design: Using List View for presentation in Delphi

To show a list of items with icons and text on a list. The first choice come into my mind is TListView. However, after doing some research on the VCL components, I found out there are alternative ways to do such presentation:
  1. TListView
  2. TcxListView
  3. TFlowPanel
  4. TcxGridCardView
  5. TScrollBox
Each component has their pros can cons. Here are the outcome of the research I have done:


Native Windows Control Wrapper VCL Component provide excellent upgrade and migration path in future. Use DoubleBuffered provide flicker free images when resize control during runtime. However, the TListView come with Delphi doesn't provide Tile view and Group View as seen on Windows XP windows explorer. To perform such view, please refer to :

1. Title: The ListView grouping feature (in Windows XP)
Author: Fabio Lucarelli

2. Title: The ListView “Tile” view feature
Author: Fabio Lucarelli

TcxListView by DevExpress

TcxListView is similar to TListView. However, it suffer from heavy flickering when resize form. The DoubleBuffered doesn't help at this point.


TFlowPanel provide good arragement on the control hosted on flow panel. However, the lack of scrolling support make it inappropriate here.

TcxGridCardView by DevExpress

TcxGridCardView is another component that able to provide similar functionanities as TListView. The strong canvas drawing events make the the card view able to draw graphics on the view:

procedure TForm1.cxGrid1CardView1CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
var R: TRect;
B: TBitmap;
if AViewInfo is TcxGridCardRowCaptionViewInfo then begin
R := AViewInfo.Bounds;
R.Top := R.Top + ImageList1.Height;

B := TBitmap.Create;
B.Height := FImage.Graphic.Height;
B.Width := FImage.Graphic.Width;
B.Canvas.Brush.Color := clWindow;
B.Canvas.FillRect(Rect(0, 0, B.Width, B.Height));
FImage.Graphic.Transparent := True;
B.Canvas.Draw(0, 0, FImage.Graphic);
B.Transparent := True;
ACanvas.Draw(AViewInfo.ContentBounds.Left, AViewInfo.ContentBounds.Top, B);

ADone := True;


TScrollBox provide scrolling support but we have to arrange the items that involve lot of coding. It is not a wise choice.


Post a Comment

<< Home