如何在代码中隐藏/显示 cxGrid 列?我试过:cxGrid2dbtableview1.Columns[mycolumnname].Visible :=False;
但它似乎并不适用。我在这里错过了什么?
问问题
4226 次
2 回答
2
如果要通过字段名识别列
var
C:TcxGridDBColumn;
begin
C := View.GetColumnByFieldName('cx1');
if Assigned(C) then C.Visible := not C.Visible;
end;
于 2013-04-13T05:35:18.570 回答
1
Columns 集合按整数索引,而不是按列名。相反,尝试cxGrid2dbtableview1.Columns[mycolumnname.index].Visible :=False;
另一种方式是直接设置列对象的Visible属性,cxGrid1Column1.Visible := False;
对于在运行时创建的列,请使用 Ken 的答案。
于 2013-04-13T02:48:13.323 回答