Spread for ASP.NET 11 Product Documentation
ButtonCellType Constructor(String,ButtonType)
Example 


FarPoint.Web.Spread Assembly > FarPoint.Web.Spread Namespace > ButtonCellType Class > ButtonCellType Constructor : ButtonCellType Constructor(String,ButtonType)
String of command to perform when the user clicks the button
Button type
Creates a new button cell with the specified command and button type.
Syntax
'Declaration
 
Public Function New( _
   ByVal cmd As String, _
   ByVal type As ButtonType _
)
'Usage
 
Dim cmd As String
Dim type As ButtonType
 
Dim instance As New ButtonCellType(cmd, type)
public ButtonCellType( 
   string cmd,
   ButtonType type
)

Parameters

cmd
String of command to perform when the user clicks the button
type
Button type
Example
This example shows the use of this constructor by creating a spreadsheet, setting the first two columns of cells to be button cells and constructing the buttons with a CommandNames of "MyRed" and "MyBlue". (In the ButtonCommand event the CommandNames are queried and the background color of the spreadsheet is changed depending on the CommandName.)
FarPoint.Web.Spread.ButtonCellType btn= new FarPoint.Web.Spread.ButtonCellType("MyRed",ButtonType.PushButton);
FarPoint.Web.Spread.ButtonCellType btn1= new FarPoint.Web.Spread.ButtonCellType("MyBlue",ButtonType.PushButton);
FarPoint.Web.Spread.StyleInfo style=new FarPoint.Web.Spread.StyleInfo();
FarPoint.Web.Spread.StyleInfo style1=new FarPoint.Web.Spread.StyleInfo();
FpSpread1.Sheets[0].ColumnCount=7;
FpSpread1.Sheets[0].RowCount=50;
style.CellType=btn;
style1.CellType=btn1;
FpSpread1.Sheets[0].SetStyleInfo(-1,0,style);
FpSpread1.Sheets[0].SetStyleInfo(-1,1,style1);
private void FpSpread1_ButtonCommand(object sender,FarPoint.Web.Spread.SpreadCommandEventArgs e)
{
If(e.CommandName=="MyRed")
{
FpSpread1.Sheets[0].BackColor=Color.Red;
}
ElseIf(e.CommandName=="MyBlue")
{
FpSpread1.Sheets[0].BackColor=Color.Blue;
}
}
Dim btn As New FarPoint.Web.Spread.ButtonCellType("MyRed",ButtonType.PushButton)
Dim btn1 As New FarPoint.Web.Spread.ButtonCellType("MyBlue",ButtonType.PushButton)
Dim style As New FarPoint.Web.Spread.StyleInfo()
Dim style1 As New FarPoint.Web.Spread.StyleInfo()
FpSpread1.Sheets(0).ColumnCount=7
FpSpread1.Sheets(0).RowCount=50
style.CellType=btn
style1.CellType=btn1
FpSpread1.Sheets(0).SetStyleInfo(-1,0,style)
FpSpread1.Sheets(0).SetStyleInfo(-1,1,style1)

Private Sub FpSpread1_ButtonCommand(ByVal sender As Object,ByVal e As FarPoint.Web.Spread.SpreadCommandEventArgs)Handles FpSpread1.ButtonCommand
If e.CommandName="MyRed"Then
FpSpread1.Sheets(0).BackColor=Color.Red
ElseIf e.CommandName="MyBlue"Then
FpSpread1.Sheets(0).BackColor=Color.Blue
End If
End Sub
See Also

Reference

ButtonCellType Class
ButtonCellType Members
Overload List
CommandName Property
ButtonType Property