GrapeCity SPREAD for WPF 2.0J
Command プロパティ (ButtonCellType)

このボタンが押されたときに呼び出すコマンドを取得または設定します。
構文
'Declaration
 
Public Property Command As ICommand
public ICommand Command {get; set;}

プロパティ値

このボタンが押されたときに呼び出すコマンド。既定値は null 参照 (Visual Basicでは Nothing) です。
次のサンプルは ButtonCellType の使用方法を説明します。このサンプルでは、ボタンがクリックされたときに行を削除します。
public void SetButtonCommand()
{
    ButtonCellType button = new ButtonCellType();
    button.Content = "Delete";
    button.Command = new MyDeleteCommand(gcSpreadGrid1);
    gcSpreadGrid1.Columns[1].CellType = button;
}

public class MyDeleteCommand : ICommand
{
    private GcSpreadGrid _gcSpreadGrid;
    public MyDeleteCommand(GcSpreadGrid gcSpreadGrid1)
    {
        this._gcSpreadGrid = gcSpreadGrid1;
    }
    public bool CanExecute(object parameter)
    {
        return true;
    }

    public event EventHandler CanExecuteChanged;

    public void Execute(object parameter)
    {
        CellCommandParameter cellCommandParameter = (CellCommandParameter)parameter;
        if (cellCommandParameter.Area == SpreadArea.Cells)
        {
            this._gcSpreadGrid.Rows.Remove(cellCommandParameter.CellPosition.Row);
        }
    }
}
Public Sub SetButtonCommand()
    Dim button As New ButtonCellType()
    button.Content = "Delete"
    button.Command = New MyDeleteCommand(gcSpreadGrid1)
    gcSpreadGrid1.Columns(1).CellType = button
End Sub

Public Class MyDeleteCommand
    Implements ICommand
    Private _gcSpreadGrid As GcSpreadGrid
    Public Sub New(gcSpreadGrid1 As GcSpreadGrid)
        Me._gcSpreadGrid = gcSpreadGrid1
    End Sub
    Public Function CanExecute(parameter As Object) As Boolean Implements ICommand.CanExecute
        Return True
    End Function

    Public Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged

    Public Sub Execute(parameter As Object) Implements ICommand.Execute
        Dim cellCommandParameter As CellCommandParameter = DirectCast(parameter, CellCommandParameter)
        If cellCommandParameter.Area = SpreadArea.Cells Then
            Me._gcSpreadGrid.Rows.Remove(cellCommandParameter.CellPosition.Row)
        End If
    End Sub
End Class
参照

ButtonCellType クラス
ButtonCellType メンバ

 

 


Copyright © 2012 GrapeCity inc. All rights reserved.