Best way to fake a non scrollable data column as an additional RowHeader column

Posted by: j2associates on 8 September 2017, 12:28 pm EST

  • Posted 8 September 2017, 12:28 pm EST

    Hello,


    I need to have a column with ComboBoxCellType look like it is a RowHeader column. I remember seeing posts about faking it but I am not sure of all of the steps that I would need to do. I think that I need the following list at a minimum. Are there other things that I am missing?



    • Freeze the column so it doesn't scroll

    • Set the BackGround color to match the header - not sure how to do this since header rows show color as Empty

    Thanks in advance for any ideas and/or suggestions!


     

  • Replied 8 September 2017, 12:28 pm EST

    j2 -

    You will need to freeze the column but it's a little more involved than that.  There is no way to set the backcolor of the editable portion of the combobox directly from the class itself.  You would need to create your own class and do the painting from there.  I did not change the color of the dropdown list since I didn't know if that was an issue or not.  You can do that in code by assigning a ListBox to the combobox and setting it's backcolor...

    Public Class mycomb
    Inherits FarPoint.Win.Spread.CellType.ComboBoxCellType

    Public Overrides Function Format(ByVal obj As Object) As String
    Return MyBase.Format(obj)
    End Function

    Public Overrides Function GetEditorControl(ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal zoomFactor As Single) As System.Windows.Forms.Control
    appearance.BackColor = System.Drawing.SystemColors.Control

    Return MyBase.GetEditorControl(appearance, zoomFactor)
    End Function

    Public Overrides Function GetEditorValue() As Object
    Return MyBase.GetEditorValue()
    End Function

    Public Overloads Overrides Function GetPreferredSize(ByVal g As System.Drawing.Graphics, ByVal size As System.Drawing.Size, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal zoomFactor As Single) As System.Drawing.Size
    Return MyBase.GetPreferredSize(g, size, appearance, value, zoomFactor)
    End Function

    Public Overrides Sub PaintCell(ByVal g As System.Drawing.Graphics, ByVal r As System.Drawing.Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)

    appearance.BackColor = System.Drawing.SystemColors.Control
    MyBase.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor)

    End Sub

    Public Overrides Function Parse(ByVal s As String) As Object
    Return MyBase.Parse(s)
    End Function

    Public Overrides Sub SetEditorValue(ByVal value As Object)

    End Sub
    End Class
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels