2013-04-13 71 views
0

如何在代码中隐藏/显示cxGrid列?我试过:cxGrid2dbtableview1.Columns[mycolumnname].Visible :=False; 但它似乎并不适用。我在这里错过了什么?cxGrid隐藏列

回答

2

如果您想通过字段名

var 
C:TcxGridDBColumn; 
begin 
C := View.GetColumnByFieldName('cx1'); 
if Assigned(C) then C.Visible := not C.Visible;  
end; 
标识列
1

Columns集合是按整数索引的,而不是列名称。相反,尝试cxGrid2dbtableview1.Columns[mycolumnname.index].Visible :=False;

另一种方法是直接设置列对象的Visible属性,cxGrid1Column1.Visible := False;

在运行时创建的列,使用肯的回答。