cxDBTreeList中的列宽

时间:2014-11-09 10:41:21

标签: delphi devexpress

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

procedure Tform1.FormResize(Sender: TObject);
 begin
  lable1.Caption := IntToStr(cxDBTreeList1.Columns[0].Width);
 end;

但是,在调整表单大小后,列大小不会更改。 感谢

1 个答案:

答案 0 :(得分:0)

好的,我可以重现那个。

原因很简单:我认为您会发现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 属性在运行时更新,以反映因更改列标题宽度而导致的任何更改。

相关问题