使冻结行不参与排序和过滤

发布时间:2012/11/13 00:11 发布者:葡萄城产品团队

返回博客中心

我们经常使用冻结行去显示合计信息,同时使用过滤、排序去选择查看信息。下面就通过实例讲解怎样使冻结行不参与过滤和排序。

1.初始化 Spread

 
private void InitSpread()

        {

            //设置行列数

            this.fpSpread1.Sheets[0].RowCount = 10;

            this.fpSpread1.Sheets[0].ColumnCount = 10;

            //设置可排序、过滤列

            this.fpSpread1.Sheets[0].Columns[0].AllowAutoSort = true;

            this.fpSpread1.Sheets[0].Columns[1].AllowAutoFilter = true;



            //设置冻结行

            this.fpSpread1.Sheets[0].FrozenTrailingRowCount = 2;

            this.fpSpread1.Sheets[0].FrozenRowCount = 1;

        }

复制代码

2.通过 UnfilteredRows 设置不可过滤行

 
private void SetUnfilterRow()

        {

            int[] unfilterRows=new int[3]{0,8,9};

            this.fpSpread1.Sheets[0].RowFilter.UnfilteredRows = unfilterRows;

        }

复制代码

3.通过 SortRows 设置不可排序行

 
bool ascending = true;

        private void fpSpread1_AutoSortingColumn(object sender, FarPoint.Win.Spread.AutoSortingColumnEventArgs e)

        {

            e.Cancel = true;

            ascending = !ascending;

            //设置可排序行

            this.fpSpread1.Sheets[0].SortRows(1, 4, new FarPoint.Win.Spread.SortInfo[] { new 



FarPoint.Win.Spread.SortInfo(e.Column, ascending) });

        }

复制代码

操作前图片展示:

排序后图片展示:

过滤图片展示:


Demo 下载:
测试环境:VS 2010 && Spread for WinForm 5.0

test.zip (46.94 K, 下载次数:22)

关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网