如何在cxGrid非绑定模式下隐藏行

问题描述 投票:0回答:1

如何在cxGrid非绑定模式下隐藏行?

已经有几个小时了,我无法弄清楚。我用谷歌搜索失败了。

delphi delphi-xe2 tcxgrid
1个回答
1
投票

[我刚刚在unbound mode中创建了一个带有网格的示例应用程序,并按照OnFilterRecord在其DevExpress中的建议使用了recommendation,并且运行良好。

下面您可以看到我的测试代码:

type
  TForm1 = class(TForm)
    testLevel: TcxGridLevel;
    testGrid: TcxGrid;
    testView: TcxGridTableView;
    testViewColumn1: TcxGridColumn;
    testViewColumn2: TcxGridColumn;
    procedure FormCreate(Sender: TObject);
    procedure tviewDataControllerFilterRecord(
      ADataController: TcxCustomDataController; ARecordIndex: Integer;
      var Accept: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  testView.DataController.RecordCount := testView.DataController.RecordCount + 1;
  testView.DataController.Values[testView.DataController.RecordCount - 1,0] := 'foo';
  testView.DataController.Values[testView.DataController.RecordCount - 1,1] := 'bar';

  testView.DataController.RecordCount := testView.DataController.RecordCount + 1;
  testView.DataController.Values[testView.DataController.RecordCount - 1,0] := 'foo2';
  testView.DataController.Values[testView.DataController.RecordCount - 1,1] := 'bar2';
end;

procedure TForm1.tviewDataControllerFilterRecord(
  ADataController: TcxCustomDataController; ARecordIndex: Integer;
  var Accept: Boolean);
begin
  Accept := (testView.DataController.Values[ARecordIndex,0] <> 'foo');
end;

结果:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9GQThySy5wbmcifQ==” alt =“在未绑定cxGrid中隐藏行”>


0
投票

已经填充网格后,如何使用此事件触发过滤?

© www.soinside.com 2019 - 2024. All rights reserved.