Spread Windows Forms 8.0 Product Documentation
GetPreferredSize(Control) Method
Example 


Name of editor control
Gets the preferred (maximum required) size of the editor control.
Syntax
'Declaration
 
Public Overloads Overrides Function GetPreferredSize( _
   ByVal editor As Control _
) As Size
'Usage
 
Dim instance As RichTextCellType
Dim editor As Control
Dim value As Size
 
value = instance.GetPreferredSize(editor)
public override Size GetPreferredSize( 
   Control editor
)

Parameters

editor
Name of editor control
Remarks
This method calculates the height and width required to display the rich text in the editor control in the cell.
Example
This example returns the width of the editor control.
FarPoint.Win.Spread.CellType.RichTextCellType rtb;

private void Form1Load(object sender, System.EventArgs e)
{
      rtb = new FarPoint.Win.Spread.CellType.RichTextCellType();
      rtb.Multiline = true;
      fpSpread1.ActiveSheet.Cells[0, 0].CellType = rtb;
      System.IO.StreamReader file = new System.IO.StreamReader(Application.StartupPath + "\\test.rtf");
      string words = file.ReadToEnd();
      fpSpread1.ActiveSheet.Cells[0, 0].Value = words;
}

private void fpSpread1EditModeOn(object sender, System.EventArgs e)
{
      Size s;
      s = rtb.GetPreferredSize(fpSpread1.EditingControl);
      MessageBox.Show("The width of the editor is " + s.Width.ToString());
}
Dim rtb As New FarPoint.Win.Spread.CellType.RichTextCellType

Private Sub Form1Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      rtb.Multiline = True
      FpSpread1.ActiveSheet.Cells(0, 0).CellType = rtb
      Dim file As New System.IO.StreamReader(Application.StartupPath & "\test.rtf")
      Dim words As String = file.ReadToEnd()
      FpSpread1.ActiveSheet.Cells(0, 0).Value = words
End Sub

Private Sub FpSpread1EditModeOn(ByVal sender As Object, ByVal e As System.EventArgs) Handles FpSpread1.EditModeOn
      Dim s As Size
      s = rtb.GetPreferredSize(FpSpread1.EditingControl)
      MessageBox.Show("The width of the editor is " & s.Width.ToString())
End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8

See Also

Reference

RichTextCellType Class
RichTextCellType Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.