Creates a new button cell with the specified command and button type.
Syntax
Parameters
- cmd
- String of command to perform when the user clicks the button
- type
- Button type
- urlOrText
- Image URL if the button type is ButtonType.ImageButton; otherwise, the button text
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.)
C# | Copy Code |
---|
FpSpread1.Sheets[0].ColumnCount=7;
FpSpread1.Sheets[0].RowCount=50;
FarPoint.Web.Spread.ButtonCellType btn=new FarPoint.Web.Spread.ButtonCellType("MyRed",ButtonType.PushButton,"Red");
FarPoint.Web.Spread.ButtonCellType btn1=new FarPoint.Web.Spread.ButtonCellType("MyBlue",ButtonType.PushButton,"Blue");
FarPoint.Web.Spread.StyleInfo style=new FarPoint.Web.Spread.StyleInfo();
FarPoint.Web.Spread.StyleInfo style1=new FarPoint.Web.Spread.StyleInfo();
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;
}
else if(e.CommandName=="MyBlue")
{
FpSpread1.Sheets[0].BackColor=Color.Blue;
}
} |
Visual Basic | Copy Code |
---|
DimbtnAsNewFarPoint.Web.Spread.ButtonCellType("MyRed",ButtonType.PushButton,"Red")
Dimbtn1AsNewFarPoint.Web.Spread.ButtonCellType("MyBlue",ButtonType.PushButton,"Blue")
DimstyleAsNewFarPoint.Web.Spread.StyleInfo()
Dimstyle1AsNewFarPoint.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)
PrivateSubFpSpread1_ButtonCommand(ByValsenderAsObject,ByValeAsFarPoint.Web.Spread.SpreadCommandEventArgs)HandlesFpSpread1.ButtonCommand
Ife.CommandName="MyRed"Then
FpSpread1.Sheets(0).BackColor=Color.Red
ElseIfe.CommandName="MyBlue"Then
FpSpread1.Sheets(0).BackColor=Color.Blue
EndIf
EndSub |
Requirements
Target Platforms: Windows 7, Windows 8, Windows Vista, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6
See Also