Spread Windows Forms 12.0 Product Documentation
ToString(Cell,ReferenceStyle) Method
Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > Cell Class > ToString Method : ToString(Cell,ReferenceStyle) Method
Cell to use for computing the relative reference
Style of cell reference
Gets a string that contains a relative reference to this cell in the specified reference style.
Syntax
'Declaration
 
Public Overloads Function ToString( _
   ByVal relativeTo As Cell, _
   ByVal referenceStyle As ReferenceStyle _
) As String
'Usage
 
Dim instance As Cell
Dim relativeTo As Cell
Dim referenceStyle As ReferenceStyle
Dim value As String
 
value = instance.ToString(relativeTo, referenceStyle)
public string ToString( 
   Cell relativeTo,
   ReferenceStyle referenceStyle
)

Parameters

relativeTo
Cell to use for computing the relative reference
referenceStyle
Style of cell reference

Return Value

String containing a relative reference to this cell in the specified reference style
Exceptions
ExceptionDescription
No cell specified or specified cell (for relative reference) is not valid
Remarks

Use this method to return the relative reference for another cell to this cell. Specify the cell for which you want the reference using the relativeTo parameter.

For example, if you want the relative reference from cell C3 to cell C1, call this method for cell C1, specifying cell C3 for the relativeTo parameter. The result is "C1", "C1", and R[-2]C, for the Default, A1, and R1C1 cell reference styles, respectively.

Header cells always return String.Empty because they cannot be referenced.

Example
This example creates a Cell object and uses its formula property to sum the values of two cells.
FarPoint.Win.Spread.Cell acell, mycell, urcell;
acell = fpSpread1.ActiveSheet.Cells[0, 0];
mycell = fpSpread1.ActiveSheet.Cells[2, 2];
urcell = fpSpread1.ActiveSheet.Cells[2, 3];
fpSpread1.ActiveSheet.Cells[2, 2].Value = 10;
fpSpread1.ActiveSheet.Cells[2, 3].Value = 10;
acell.Formula = "SUM(" + mycell.ToString(urcell, FarPoint.Win.Spread.Model.ReferenceStyle.A1) + "," + urcell.ToString(mycell,
FarPoint.Win.Spread.Model.ReferenceStyle.A1) + ")";
Dim acell, mycell, urcell As FarPoint.Win.Spread.Cell
acell = fpSpread1.ActiveSheet.Cells(0, 0)
mycell = fpSpread1.ActiveSheet.Cells(2, 2)
urcell = fpSpread1.ActiveSheet.Cells(2, 3)
fpSpread1.ActiveSheet.Cells(2, 3).Value = 10
fpSpread1.ActiveSheet.Cells(2, 2).Value = 10
acell.Formula = "SUM(" + mycell.ToString(urcell, FarPoint.Win.Spread.Model.ReferenceStyle.A1) + "," + urcell.ToString(mycell,
FarPoint.Win.Spread.Model.ReferenceStyle.A1) + ")"
See Also

Reference

Cell Class
Cell Members
Overload List