Does WorkAreas work on ListViews in Delphi?

I played with TListView and tried to figure out how WorkAreas work and what they are useful for. It seems to have very little documentation (big surprise).

Has anyone successfully used WorkAreas? If so, why?

I tried things like:

  wa := ListView1.WorkAreas.Add;
  wa.DisplayName := 'Work Area 0';
  wa.Rect.Width := ListView1.Width div 2;
  wa.Rect.Height := ListView1.Height;

which appears to be creating a workspace area, and you can determine if an item is associated with this workspace by checking its WorkArea property.

+5
source share
1 answer

This is VCL support for native List-View management workspaces. See List-View workspaces . The documentation provides an example of what they can be used for:

[...] . , . , / . , . [...]

, , .

VCL, , . . , . , , . , (VCL , , ).

, , , . , , . , , .


:
type
  TForm1 = class(TForm)
    Button1: TButton;
    ListView1: TListView;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

uses
  commctrl;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  R1, R2: TRect;
begin
  R1 := Rect(0, 0,
              ListView1.ClientWidth div 2, ListView1.ClientHeight div 2 + 10);
  R2 := Rect(ListView1.ClientWidth div 2 + 1, 0,
              ListView1.ClientWidth - 1, ListView1.ClientHeight div 2 + 10);

  ListView1.WorkAreas.Add.Rect := R1;
  ListView1.WorkAreas.Add.Rect := R2;

  ListView1.AddItem('Item 1', nil);
  ListView1.AddItem('Item 2', nil);
  ListView1.AddItem('Item 3', nil);
  ListView1.AddItem('Item 4', nil);
  ListView1.AddItem('Item 5', nil);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  for i := 0 to ListView1.Items.Count - 1 do begin
    ListView1.Items[i].Left := ListView1.WorkAreas[1].Rect.Left;
    ListView1.Items[i].Top := ListView1.WorkAreas[1].Rect.Top;
  end;
  ListView1.Arrange(arAlignTop);
end;


:
enter image description here
:
enter image description here

, " 5" - . " ". , " 5" , "Item-1", . , , . , , .

+6

All Articles