ヘッダセルのテキストの一部が正しく描画されない場合がある
対象製品
SPREAD for Windows Forms 7.0J
状況
修正済み
詳細
ヘッダセルのテキストの一部が正しく描画されない場合があります。
【手順】
1.新規フォームにSPREADを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
--列ヘッダA1セルのテキストの一部が描画されません
【サンプルコード】
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ヘッダセルの設定
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Value = "グループ"
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Font = New Font("MS ゴシック", 12.0F)
FpSpread1.ActiveSheet.ColumnHeader.Rows(0).Height = 31
' 列幅の設定
FpSpread1.ActiveSheet.Columns(0).Width = 100
End Sub
【手順】
1.新規フォームにSPREADを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
--列ヘッダA1セルのテキストの一部が描画されません
【サンプルコード】
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ヘッダセルの設定
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Value = "グループ"
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Font = New Font("MS ゴシック", 12.0F)
FpSpread1.ActiveSheet.ColumnHeader.Rows(0).Height = 31
' 列幅の設定
FpSpread1.ActiveSheet.Columns(0).Width = 100
End Sub
回避方法
Service Pack 5(v7.0.2018.2008)で修正済み。
Service Pack 5(v7.0.2018.2008)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
以下のサンプルコードのように独自のRendererを使用します。
【サンプルコード】
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ヘッダセルの設定
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Value = "グループ"
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Font = New Font("MS ゴシック", 12.0F)
FpSpread1.ActiveSheet.ColumnHeader.Rows(0).Height = 31
' 列幅の設定
FpSpread1.ActiveSheet.Columns(0).Width = 100
' 回避策[1/2]
Dim defaultHeaderRenderer1 As FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer = TryCast(FpSpread1.ActiveSheet.Models.ColumnHeaderStyle.GetCompositeInfo(0, 0, 0, Nothing).Renderer, FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer)
If defaultHeaderRenderer1 IsNot Nothing Then
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Renderer = New CustomHeaderRenderer(defaultHeaderRenderer1)
End If
' 回避策[1/2]
End Sub
' 回避策[2/2]
Public Class CustomHeaderRenderer
Inherits FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer
Private headerRendere As FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer
Public Sub New(ByVal defaultHeaderRenderer As FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer)
Me.headerRendere = defaultHeaderRenderer
End Sub
Public Overrides Sub PaintHeader(ByVal g As Graphics, ByVal r As Rectangle, ByVal rectTextIn As Rectangle, ByVal backColor As Color, ByVal foreColor As Color, ByVal font As Font, ByVal halign As FarPoint.Win.HorizontalAlignment, ByVal valign As FarPoint.Win.VerticalAlignment, ByVal pressed As Boolean, ByVal focus As Boolean, ByVal text As String, ByVal textDown As String, ByVal nAlign As FarPoint.Win.ButtonTextAlign, ByVal textOrientation As FarPoint.Win.TextOrientation, ByVal wordWrap As Boolean, ByVal shadowSize As Integer, ByVal darkColor As Color, ByVal lightColor As Color, ByVal pictUp As Image, ByVal pictDown As Image, ByVal bLocked As Boolean, ByVal prefix As System.Drawing.Text.HotkeyPrefix, ByVal style As FarPoint.Win.VisualStyles, ByVal mouseOver As Boolean, ByVal rightToLeft As Boolean, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal textRotationAngle As Double, ByVal zoomFactor As Single)
Dim s As String = (If(pressed AndAlso textDown IsNot Nothing, textDown, text))
If valign = FarPoint.Win.VerticalAlignment.Center AndAlso (r.Height - FarPoint.Win.ElementWindowless.GetRotatedTextSize(g, s, font, rectTextIn, textOrientation, wordWrap, prefix, StringTrimming.None, textRotationAngle).Height) Mod 2 = 1 Then
rectTextIn.Height -= 1
End If
headerRendere.PaintHeader(g, r, rectTextIn, backColor, foreColor, font, halign, valign, pressed, focus, text, textDown, nAlign, textOrientation, wordWrap, shadowSize, darkColor, lightColor, pictUp, pictDown, bLocked, prefix, style, mouseOver, rightToLeft, appearance, textRotationAngle, zoomFactor)
End Sub
End Class
' 回避策[2/2]
Service Pack 5(v7.0.2018.2008)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
以下のサンプルコードのように独自のRendererを使用します。
【サンプルコード】
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ヘッダセルの設定
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Value = "グループ"
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Font = New Font("MS ゴシック", 12.0F)
FpSpread1.ActiveSheet.ColumnHeader.Rows(0).Height = 31
' 列幅の設定
FpSpread1.ActiveSheet.Columns(0).Width = 100
' 回避策[1/2]
Dim defaultHeaderRenderer1 As FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer = TryCast(FpSpread1.ActiveSheet.Models.ColumnHeaderStyle.GetCompositeInfo(0, 0, 0, Nothing).Renderer, FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer)
If defaultHeaderRenderer1 IsNot Nothing Then
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 0).Renderer = New CustomHeaderRenderer(defaultHeaderRenderer1)
End If
' 回避策[1/2]
End Sub
' 回避策[2/2]
Inherits FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer
Private headerRendere As FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer
Public Sub New(ByVal defaultHeaderRenderer As FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer)
Me.headerRendere = defaultHeaderRenderer
End Sub
Public Overrides Sub PaintHeader(ByVal g As Graphics, ByVal r As Rectangle, ByVal rectTextIn As Rectangle, ByVal backColor As Color, ByVal foreColor As Color, ByVal font As Font, ByVal halign As FarPoint.Win.HorizontalAlignment, ByVal valign As FarPoint.Win.VerticalAlignment, ByVal pressed As Boolean, ByVal focus As Boolean, ByVal text As String, ByVal textDown As String, ByVal nAlign As FarPoint.Win.ButtonTextAlign, ByVal textOrientation As FarPoint.Win.TextOrientation, ByVal wordWrap As Boolean, ByVal shadowSize As Integer, ByVal darkColor As Color, ByVal lightColor As Color, ByVal pictUp As Image, ByVal pictDown As Image, ByVal bLocked As Boolean, ByVal prefix As System.Drawing.Text.HotkeyPrefix, ByVal style As FarPoint.Win.VisualStyles, ByVal mouseOver As Boolean, ByVal rightToLeft As Boolean, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal textRotationAngle As Double, ByVal zoomFactor As Single)
Dim s As String = (If(pressed AndAlso textDown IsNot Nothing, textDown, text))
If valign = FarPoint.Win.VerticalAlignment.Center AndAlso (r.Height - FarPoint.Win.ElementWindowless.GetRotatedTextSize(g, s, font, rectTextIn, textOrientation, wordWrap, prefix, StringTrimming.None, textRotationAngle).Height) Mod 2 = 1 Then
rectTextIn.Height -= 1
End If
headerRendere.PaintHeader(g, r, rectTextIn, backColor, foreColor, font, halign, valign, pressed, focus, text, textDown, nAlign, textOrientation, wordWrap, shadowSize, darkColor, lightColor, pictUp, pictDown, bLocked, prefix, style, mouseOver, rightToLeft, appearance, textRotationAngle, zoomFactor)
End Sub
End Class
' 回避策[2/2]