public void SetCheckBoxCommand() { CheckBoxCellType checkbox = new CheckBoxCellType(); checkbox.TrueContent = "Yes"; checkbox.FalseContent = "No"; checkbox.Command = new MyCommand(gcSpreadGrid1); gcSpreadGrid1.Columns[1].CellType = checkbox; } class MyCommand : ICommand { private GcSpreadGrid _gcSpreadGrid; public MyCommand(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) { MessageBox.Show(this._gcSpreadGrid.ActiveCell.Value.ToString()); } } }
Public Sub SetCheckBoxCommand() Dim checkbox As New CheckBoxCellType() checkbox.TrueContent = "Yes" checkbox.FalseContent = "No" checkbox.Command = New MyCommand(gcSpreadGrid1) gcSpreadGrid1.Columns(1).CellType = checkbox End Sub Private Class MyCommand 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 MessageBox.Show(Me._gcSpreadGrid.ActiveCell.Value.ToString()) End If End Sub End Class