Delphi cxDBTreeList中的列宽

Delphi cxDBTreeList中的列宽,delphi,devexpress,Delphi,Devexpress,我需要知道cxdbtreelist中列的宽度,例如: columntautowidth=true。 cxdbtreelist.align=altop procedure Tform1.FormResize(Sender: TObject); begin lable1.Caption := IntToStr(cxDBTreeList1.Columns[0].Width); end; 但是,调整表单大小后,列大小不会改变。 谢谢好的,我可以复制一下 原因很简单:我想您会发现OLH表示列的宽

我需要知道cxdbtreelist中列的宽度,例如: columntautowidth=true。 cxdbtreelist.align=altop

procedure Tform1.FormResize(Sender: TObject);
 begin
  lable1.Caption := IntToStr(cxDBTreeList1.Columns[0].Width);
 end;
但是,调整表单大小后,列大小不会改变。
谢谢

好的,我可以复制一下

原因很简单:我想您会发现OLH表示列的宽度是设计器中设置的值。列的DisplayWidth是反映其当前屏幕宽度的属性。试试这个:

procedure TForm1.ShowColWidth(ColNo : Integer);
begin
  Caption := IntToStr(cxDBTreeList1.Columns[ColNo].Width) + '/' +  IntToStr(cxDBTreeList1.Columns[ColNo].DisplayWidth); 
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowColWidth(0);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  ShowColWidth(0);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  ShowColWidth(0);
end;

您会发现Width属性在运行时更新,以反映更改列标题宽度所引起的任何更改。

您是说“lable1.Caption”显示的值没有更改,还是列[0]的屏幕宽度没有更改?lable1.Caption显示的值没有更改