作成日: 2019/07/22 最終更新日: 2019/07/22
文書種別
使用方法
詳細
文字列のサイズを判定してセルノートのサイズに反映させることで自動調整が可能です。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' セルノートの設定
FpSpread1.ActiveSheet.Cells(0, 0).Note = "テスト"
FpSpread1.ActiveSheet.Cells(0, 0).NoteStyle = FarPoint.Win.Spread.NoteStyle.PopupStickyNote
' 文字列のサイズ取得
Dim size As Size
Dim text As String = FpSpread1.ActiveSheet.Cells(0, 0).Note
Dim font As Font = New Font("メイリオ", 10)
Using g As Graphics = FpSpread1.CreateGraphics()
size = g.MeasureString(text, font).ToSize()
End Using
' セルノートの外観の設定
Dim noteInfo As New FarPoint.Win.Spread.DrawingSpace.StickyNoteStyleInfo
noteInfo.Font = font
noteInfo.ForeColor = Color.Blue
noteInfo.MarginLeft = 5
noteInfo.MarginTop = 5
noteInfo.MarginRight = 5
noteInfo.MarginBottom = 5
noteInfo.TextWrap = False
noteInfo.Width = size.Width + noteInfo.MarginLeft + noteInfo.MarginRight + SystemInformation.BorderSize.Width * 2
noteInfo.Height = size.Height + noteInfo.MarginTop + noteInfo.MarginBottom + SystemInformation.BorderSize.Height * 2
FpSpread1.ActiveSheet.SetStickyNoteStyleInfo(0, 0, noteInfo)
End Sub
' セルノートの設定
FpSpread1.ActiveSheet.Cells(0, 0).Note = "テスト"
FpSpread1.ActiveSheet.Cells(0, 0).NoteStyle = FarPoint.Win.Spread.NoteStyle.PopupStickyNote
' 文字列のサイズ取得
Dim size As Size
Dim text As String = FpSpread1.ActiveSheet.Cells(0, 0).Note
Dim font As Font = New Font("メイリオ", 10)
Using g As Graphics = FpSpread1.CreateGraphics()
size = g.MeasureString(text, font).ToSize()
End Using
' セルノートの外観の設定
Dim noteInfo As New FarPoint.Win.Spread.DrawingSpace.StickyNoteStyleInfo
noteInfo.Font = font
noteInfo.ForeColor = Color.Blue
noteInfo.MarginLeft = 5
noteInfo.MarginTop = 5
noteInfo.MarginRight = 5
noteInfo.MarginBottom = 5
noteInfo.TextWrap = False
noteInfo.Width = size.Width + noteInfo.MarginLeft + noteInfo.MarginRight + SystemInformation.BorderSize.Width * 2
noteInfo.Height = size.Height + noteInfo.MarginTop + noteInfo.MarginBottom + SystemInformation.BorderSize.Height * 2
FpSpread1.ActiveSheet.SetStickyNoteStyleInfo(0, 0, noteInfo)
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
// セルノートの設定
fpSpread1.ActiveSheet.Cells[0, 0].Note = "テスト";
fpSpread1.ActiveSheet.Cells[0, 0].NoteStyle = FarPoint.Win.Spread.NoteStyle.PopupStickyNote;
// 文字サイズの取得
Size size;
string text = fpSpread1.ActiveSheet.Cells[0, 0].Note;
Font font = new Font("メイリオ", 10);
using (Graphics g = fpSpread1.CreateGraphics())
{
size = g.MeasureString(text, font).ToSize();
}
// セルノートの外観の設定
FarPoint.Win.Spread.DrawingSpace.StickyNoteStyleInfo noteInfo = new FarPoint.Win.Spread.DrawingSpace.StickyNoteStyleInfo();
noteInfo.Font = font;
noteInfo.ForeColor = Color.Blue;
noteInfo.MarginLeft = 5;
noteInfo.MarginTop = 5;
noteInfo.MarginRight = 5;
noteInfo.MarginBottom = 5;
noteInfo.TextWrap = false;
noteInfo.Width = size.Width + noteInfo.MarginLeft + noteInfo.MarginRight + SystemInformation.BorderSize.Width * 2;
noteInfo.Height = size.Height + noteInfo.MarginTop + noteInfo.MarginBottom + SystemInformation.BorderSize.Height * 2;
fpSpread1.ActiveSheet.SetStickyNoteStyleInfo(0, 0, noteInfo);
}
{
// セルノートの設定
fpSpread1.ActiveSheet.Cells[0, 0].Note = "テスト";
fpSpread1.ActiveSheet.Cells[0, 0].NoteStyle = FarPoint.Win.Spread.NoteStyle.PopupStickyNote;
// 文字サイズの取得
Size size;
string text = fpSpread1.ActiveSheet.Cells[0, 0].Note;
Font font = new Font("メイリオ", 10);
using (Graphics g = fpSpread1.CreateGraphics())
{
size = g.MeasureString(text, font).ToSize();
}
// セルノートの外観の設定
FarPoint.Win.Spread.DrawingSpace.StickyNoteStyleInfo noteInfo = new FarPoint.Win.Spread.DrawingSpace.StickyNoteStyleInfo();
noteInfo.Font = font;
noteInfo.ForeColor = Color.Blue;
noteInfo.MarginLeft = 5;
noteInfo.MarginTop = 5;
noteInfo.MarginRight = 5;
noteInfo.MarginBottom = 5;
noteInfo.TextWrap = false;
noteInfo.Width = size.Width + noteInfo.MarginLeft + noteInfo.MarginRight + SystemInformation.BorderSize.Width * 2;
noteInfo.Height = size.Height + noteInfo.MarginTop + noteInfo.MarginBottom + SystemInformation.BorderSize.Height * 2;
fpSpread1.ActiveSheet.SetStickyNoteStyleInfo(0, 0, noteInfo);
}
旧文書番号
84292