コンボボックス型セルのListWidthがゼロ(0)でドロップダウンリストの先頭の項目が空文字の場合、Windows Server 2012上でドロップダウンリストが正しく表示されないことがある

文書番号 : 37695     文書種別 : 不具合     登録日 : 2014/12/02     最終更新日 : 2014/12/15
文書を印刷する
対象製品
SPREAD for Windows Forms 7.0J
状況
修正済み
詳細
コンボボックス型セルのListWidthをゼロ(0)に設定し、ドロップダウンリストの先頭の項目が空文字の場合、Windows Server 2012上でドロップダウンリストが正しく表示されないことがあります。

【手順】
1.新規フォームにSPREADを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.B1セルのドロップダウンボタンを何度かクリックします
  --ドロップダウンリストが正しく描画されない場合があります

【サンプルコード】
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim comboType As New FarPoint.Win.Spread.CellType.ComboBoxCellType()
    comboType.Items = New String() {"", "東京", "大阪", "福岡"}
    comboType.ListWidth = 0
    FpSpread1.ActiveSheet.Columns(1).CellType = comboType
  End Sub
回避方法
Service Pack 4(v7.0.2016.2008)で修正済み。
Service Pack 4(v7.0.2016.2008)より前のバージョンでは次の回避方法が有効です。
------------------------------------------

ComboDropDownイベントでサイズを明示的に設定します。

【サンプルコード】
  Private Sub FpSpread1_ComboDropDown(sender As Object, e As FarPoint.Win.Spread.EditorNotifyEventArgs) Handles FpSpread1.ComboDropDown
    Dim editor = e.EditingControl
    If TypeOf editor Is FarPoint.Win.FpCombo Then
      Dim comboBox As FarPoint.Win.FpCombo = CType(editor, FarPoint.Win.FpCombo)
      If (comboBox.ListWidth = 0) Then
        Dim lWidth As Integer = 0
        Dim g As Graphics = CreateGraphics()
        For i As Integer = 0 To comboBox.List.Count - 1
          Dim sz As SizeF = g.MeasureString(comboBox.List(i).ToString(), comboBox.Font)
          If sz.Width > lWidth Then
            lWidth = Convert.ToInt32(sz.Width)
          End If
        Next
        If comboBox.List.Count > comboBox.MaxDrop Then
          lWidth += SystemInformation.VerticalScrollBarWidth
        End If
        g.Dispose()
        comboBox.ListWidth = lWidth
      End If
    End If
  End Sub