ドロップダウンフィルタリスト内のデフォルトのフィルタ項目に既定で表示される内容は以下のとおりです。
フィルタリスト内の項目 |
説明 |
(All) |
セルの内容に関係なく、この列内のすべての行が含められ(許可され)ます。 |
セルデータ |
この列内で、ここで選択する特定のセルデータを持つ行だけが許可されます。 |
(Blanks) |
この列内で、空白値(空白セル)を持つ行だけが許可されます。 |
(NonBlanks) |
この列内で、空白値(空白セル)ではない行、つまり何らかのデータを持つセルだけが許可されます。 |
このフィルタ項目に表示する内容および表示テキストを設定することができます。
設定方法
セルデータ以外の「(All)」「(Blanks)」「(NonBlanks)」と表示されるフィルタ項目のテキストを変更するには、HideRowFilter クラスまたは、StyleRowFilter クラスの以下のプロパティを使用します。
フィルタリストに表示される項目は、FilterColumnDefinition クラスのコンストラクタで指定します。第2引数にFilterListBehavior 列挙型の以下の値を設定できます。なお、FilterListBehaior 列挙体はビットフィールドなので、複数の値を設定可能です。
FilterListBehaviorの値 |
説明 |
Custom |
カスタムフィルタを使用します。 |
Blank |
"(Blanks)"(空白セル) 項目を表示します。 |
NonBlank |
"(NonBlanks)"(空白以外のセル)項目を表示します。 |
DefaultFilter |
IFilterItem インタフェースのDefaultFilterItem 実装を含めます。 |
SortAlphabetically |
デフォルトのフィルタ動作を使用し、リスト項目をアルファベット順に並べ替えます。 |
Default |
Blank + NonBlank + SortAlphabeticallyを使用します。 |
SortByMostOccurrences |
リストの項目を出現頻度が高い順に並べ替えます。 |
SortByLeastOccurrences |
リストの項目を出現頻度が低い順に並べ替えます。 |
サンプルコード
次のサンプルコードは、ドロップダウンリストのフィルタ項目をカスタマイズします。
// スタイルフィルタを生成します。
FarPoint.Web.Spread.NamedStyle instyle = new FarPoint.Web.Spread.NamedStyle();
FarPoint.Web.Spread.NamedStyle outstyle = new FarPoint.Web.Spread.NamedStyle();
instyle.BackColor = Color.Yellow;
outstyle.BackColor = Color.Gray;
FarPoint.Web.Spread.StyleRowFilter rf = new FarPoint.Web.Spread.StyleRowFilter(FpSpread1.Sheets[0], instyle, outstyle);
FpSpread1.Sheets[0].RowFilter = rf;
// フィルタ項目を設定します。
FarPoint.Web.Spread.FilterColumnDefinition fd = new FarPoint.Web.Spread.FilterColumnDefinition(2, FarPoint.Web.Spread.FilterListBehavior.SortByMostOccurrences | FarPoint.Web.Spread.FilterListBehavior.Blank);
FpSpread1.Sheets[0].RowFilter.AddColumn(1);
FpSpread1.Sheets[0].RowFilter.AddColumn(fd);
// 表示テキストを変更します。
FpSpread1.Sheets[0].RowFilter.AllString = "すべて";
FpSpread1.Sheets[0].RowFilter.BlanksString = "空白セル";
FpSpread1.Sheets[0].RowFilter.NonBlanksString = "空白以外のセル";
' スタイルフィルタを生成します。
Dim instyle As New FarPoint.Web.Spread.NamedStyle()
Dim outstyle As New FarPoint.Web.Spread.NamedStyle()
instyle.BackColor = Color.Yellow
outstyle.BackColor = Color.Gray
Dim rf As New FarPoint.Web.Spread.StyleRowFilter(FpSpread1.Sheets(0), instyle, outstyle)
FpSpread1.Sheets(0).RowFilter = rf
' フィルタ項目を設定します。
Dim fd As New FarPoint.Web.Spread.FilterColumnDefinition(2, FarPoint.Web.Spread.FilterListBehavior.SortByMostOccurrences Or FarPoint.Web.Spread.FilterListBehavior.Blank)
FpSpread1.Sheets[0].RowFilter.AddColumn(1)
FpSpread1.Sheets[0].RowFilter.AddColumn(fd)
' 表示テキストを変更します。
FpSpread1.Sheets(0).RowFilter.AllString = "すべて"
FpSpread1.Sheets(0).RowFilter.BlanksString = "空白セル"
FpSpread1.Sheets(0).RowFilter.NonBlanksString = "空白以外のセル"
関連トピック