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