Spread ASP.NET 6.0 Product Documentation
Setting a Button Cell
Send Feedback
Spread ASP.NET 6.0 Product Documentation > Developer's Guide > Customizing with Cell Types > Working with Graphical Cell Types > Setting a Button Cell

Glossary Item Box

A button cell displays a rectangular button (with the word Button by default unless you specify otherwise) that behaves like a button control. You can specify the text for that button or you can substitute the entire graphic image. You can also specify text to appear underlined and blue, as a hypertext link would appear. The default appearance and the three possible alternatives are shown in this figure.

Appearances of Button Cell Types

To create a cell that acts like a button, follow this procedure.

For details on the properties and methods for this cell type, refer to the ButtonCellType class in the Assembly Reference.

Return to the overview of graphical cell types at Working with Graphical Cell Types.

Using Code

  1. Define the button cell type by creating an instance of the ButtonCellType class and specify whether it is push button, image button, or link button.
  2. Specify the properties of the button by setting the properties of that instance. Specify the text in the button or an image to use.
  3. Specify the command to execute when the button is selected.
  4. Assign the type to a cell (or cells).

Example

In this example, create a button with text in the first cell, a button with a stored image in the cell diagonally below that, and a button with link text in the one diagonally below that. These are identical to those pictured in the figure (except for placement).

C# Copy Code
FpSpread1.ActiveSheetView.Cells[0, 0].CellType = new ButtonCellType("OneCommand", ButtonType.PushButton, "Click");   
FpSpread1.ActiveSheetView.Cells[1, 1].CellType = new ButtonCellType("OneCommand", ButtonType.ImageButton, "images/addtocart.gif");
FpSpread1.ActiveSheetView.Cells[2, 2].CellType = new ButtonCellType("OneCommand", ButtonType.LinkButton, "www.fpoint.com");
VB Copy Code
Dim btnc1 As New FarPoint.Web.Spread.ButtonCellType()
btnc1.CommandName = "OneCommand"
btnc1.ButtonType = ButtonType.PushButton
btnc1.Text = "Click"
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = btnc1
  
Dim btnc2 As New FarPoint.Web.Spread.ButtonCellType()
btnc2.CommandName = "OneCommand"
btnc2.ButtonType = ButtonType.ImageButton
btnc2.ImageUrl = "addtocart.gif"
FpSpread1.ActiveSheetView.Cells(1, 1).CellType = btnc2
  
Dim btnc3 As New FarPoint.Web.Spread.ButtonCellType()
btnc3.CommandName = "OneCommand"
btnc3.ButtonType = ButtonType.LinkButton
btnc3.Text = "www.fpoint.com"
FpSpread1.ActiveSheetView.Cells(2, 2).CellType = btnc3

Using the Spread Designer

  1. In the work area, select the cell or cells for which you want to set the cell type.
  2. Select the Home menu.
  3. Select the SetCellType icon under the CellType section.
  4. Select the cell type and any other cell properties.
  5. Select OK to close the dialog.
  6. Click Apply and Exit to close the Spread Designer.
© 2002-2012 GrapeCity, Inc. All Rights Reserved.