MESCIUS SPREAD for Windows Forms 15.0J
FilterBarDropDownSelectionChanging イベント
使用例 

ユーザーがフィルタバーエディタのドロップダウンリストから値を選択したときに発生します。
構文
'宣言
 
Public Event FilterBarDropDownSelectionChanging As FilterBarDropDownSelectionChangingEventHandler
public event FilterBarDropDownSelectionChangingEventHandler FilterBarDropDownSelectionChanging
イベント データ

イベント ハンドラが、このイベントに関連するデータを含む、FilterBarDropDownSelectionChangingEventArgs 型の引数を受け取りました。次の FilterBarDropDownSelectionChangingEventArgs プロパティには、このイベントの固有の情報が記載されます。

プロパティ解説
ChangesObject新しい値。  
ColumnIndex列インデックスを指定します。  
Handled新しい値が処理されたかどうかを示します。  
使用例
次のサンプルコードは、FilterBarDropDownSelectionChangingイベントを使用します。
private void Form1_Load(object sender, EventArgs e)
        {
            System.Globalization.DateTimeFormatInfo dtf = new System.Globalization.DateTimeFormatInfo();
            dtf.LongDatePattern = "D";
            dtf.ShortDatePattern = "M/d/yyyy";

            FarPoint.Win.Spread.CellType.FilterBarCellType fbcell = new FarPoint.Win.Spread.CellType.FilterBarCellType();
            fbcell.AutoFormat = true;
            fbcell.ContextMenuType = FarPoint.Win.Spread.CellType.FilterBarContextMenuType.DateTime;
            fbcell.DateTimeFormatInfo = dtf;
            fpSpread1.Sheets[0].AutoFilterMode = FarPoint.Win.Spread.AutoFilterMode.FilterBar;
            fpSpread1.Sheets[0].FilterBar.Cells[0].CellType = fbcell;
            fpSpread1.Sheets[0].Cells[0, 0].Value = DateTime.Now;
}

        private void fpSpread1_FilterBarDropDownSelectionChanging(object sender, FarPoint.Win.Spread.CellType.FilterBarDropDownSelectionChangingEventArgs e)
        {
            if (e.ChangesObject is string) //all condition to Contains using wildcard
            {
                // e.ChangesObject = "*" + e.ChangesObject.ToString() + "*";
                //e.Handled = true; //notify to use new changed value
            }
            else if (e.ChangesObject is DateTime) //change DateTime to a short format string
            {
                //e.ChangesObject = ((DateTime)e.ChangesObject).ToShortDateString();
                FarPoint.Win.Spread.CellType.DateTimeCellType dc = new FarPoint.Win.Spread.CellType.DateTimeCellType();
                dc.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined;
                dc.UserDefinedFormat = "M/d/yy";
                //e.ChangesObject = dc.Format(e.ChangesObject);
                GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType datecell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
                GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayFieldInfo test = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayFieldInfo();
                datecell.FocusPosition = GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorFocusCursorPosition.MouseLocation;
                datecell.Spin.AllowSpin = true;
                datecell.Spin.IncrementValue = new TimeSpan(2);
                datecell.DropDownCalendar.BackColor = Color.Red;
                datecell.DropDownCalendar.CalendarDimensions = new Size(3, 1);
                datecell.DropDownCalendar.Font = new Font("Arial", 10, FontStyle.Bold);              
                datecell.DropDown.AllowDrop = true;
                datecell.DropDown.AllowResize = true;
                datecell.DropDown.AutoDropDown = true;
                datecell.DefaultActiveField = datecell.Fields[2];
                e.ChangesObject = datecell.Format(e.ChangesObject);
                e.Handled = true; //notify to use new changed value
            }
            else if (e.ChangesObject is Color) // change color or icon enumerable
            {
                if (((Color)e.ChangesObject) == Color.Red) e.ChangesObject = Color.DarkBlue;
                e.Handled = true; //notify to use new changed value
            }
            else //by default it is false, not used
                e.Handled = false; //notify to not use new changed value
        }
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dtf As New System.Globalization.DateTimeFormatInfo
        dtf.LongDatePattern = "D"
        dtf.ShortDatePattern = "M/d/yyyy"

        Dim fbcell As New FarPoint.Win.Spread.CellType.FilterBarCellType()
        fbcell.AutoFormat = True
        fbcell.ContextMenuType = FarPoint.Win.Spread.CellType.FilterBarContextMenuType.DateTime
        fbcell.DateTimeFormatInfo = dtf
        FpSpread1.Sheets(0).AutoFilterMode = FarPoint.Win.Spread.AutoFilterMode.FilterBar
        FpSpread1.Sheets(0).FilterBar.Cells(0).CellType = fbcell
        FpSpread1.Sheets(0).Cells(0, 0).Value = DateTime.Now
End Sub

 Private Sub FpSpread1_FilterBarDropDownSelectionChanging(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.CellType.FilterBarDropDownSelectionChangingEventArgs) Handles FpSpread1.FilterBarDropDownSelectionChanging
        If TypeOf e.ChangesObject Is String Then
            ' e.ChangesObject = "*" + e.ChangesObject.ToString() + "*";
            'e.Handled = true; //notify to use new changed value
            'all condition to Contains using wildcard
        ElseIf TypeOf e.ChangesObject Is DateTime Then
            'change DateTime to a short format string
            'e.ChangesObject = ((DateTime)e.ChangesObject).ToShortDateString();
            Dim dc As New FarPoint.Win.Spread.CellType.DateTimeCellType()
            dc.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined
            dc.UserDefinedFormat = "M/d/yy"
            'e.ChangesObject = dc.Format(e.ChangesObject);
            Dim datecell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType()
            Dim test As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayFieldInfo()           
            datecell.FocusPosition = GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorFocusCursorPosition.MouseLocation            
            datecell.Spin.AllowSpin = True
            datecell.Spin.IncrementValue = New TimeSpan(2)
            datecell.DropDownCalendar.BackColor = Color.Red
            datecell.DropDownCalendar.CalendarDimensions = New Size(3, 1)
            datecell.DropDownCalendar.Font = New Font("Arial", 10, FontStyle.Bold)
            'datecell.DropDownCalendar.HeaderStyle.BackColor = Color.Green;
            datecell.DropDown.AllowDrop = True
            datecell.DropDown.AllowResize = True
            datecell.DropDown.AutoDropDown = True
            datecell.DefaultActiveField = datecell.Fields(2)
            e.ChangesObject = datecell.Format(e.ChangesObject)
            'notify to use new changed value
            e.Handled = True
        ElseIf TypeOf e.ChangesObject Is Color Then
            ' change color or icon enumerable
            If DirectCast(e.ChangesObject, Color) = Color.Red Then
                e.ChangesObject = Color.DarkBlue
            End If
            'notify to use new changed value
            e.Handled = True
        Else
            'by default it is false, not used
            e.Handled = False
        End If
        'notify to not use new changed value
    End Sub
参照

FpSpread クラス
FpSpread メンバ

 

 


© MESCIUS inc. All rights reserved.