Question about the PaintCell method

Posted by: pawprint on 8 September 2017, 12:38 pm EST

  • Posted 8 September 2017, 12:38 pm EST

    Background (using Spread for WinForms 2.5): I'm trying to create a gradient header like in the Gradient sample included with Spread. What I noticed when running the sample was that when an entire column is selected, the header is drawn just like any other header (on my system, with a blue-gray color). What I would prefer to do is continue drawing the gradient but shaded with the highlight color.


    PaintCell() receives the Boolean isSelected parameter, but since the sample code wasn't testing this and therefore was clearly trying to draw the header regardless of the value of this parameter, I figured trying to use it would be useless, and it was. Is there a way to control how row and columns headers display themselves when they too need to display in a selected state?


    Since I'll be moving to version 3.0 soon, is this entire question moot? I noticed that there's apparently a GradientHeaderRenderer class in that one.

  • Replied 8 September 2017, 12:38 pm EST

    Hello,


    Yes. This will not be an issue when using the new GradientHeaderRenderer class. Also, this will fix the issue with sort indicator and filter indicators not displaying in the header. With the 2.5 version the isSelected parameter should be set when you select a header. Is this returning false?

  • Replied 8 September 2017, 12:38 pm EST

    It's not a question of whether it's set or not; it's simply that either the PaintCell() method isn't called when the header is selected or the control comes in behind and clobbers whatever you did, because I tried painting the gradient in reverse when isSelected == true and nothing happened (I just got the flat, blue-gray coloring).
  • Replied 8 September 2017, 12:38 pm EST

    Hello,


    Yes. This depends on how you have the SelectionStyle property set as to how the selection is painted. But, if you do not call the base class in the PaintCell method, then the Spread should only paint the cell how you have the code in the PaintCell override.

  • Replied 8 September 2017, 12:38 pm EST

    And just to be sure we're on the same page here, I'm talking about column and row headers, not regular data cells. Does your reply still apply?
  • Replied 8 September 2017, 12:38 pm EST

    Hello,


    One thing you need to do is to set the SelectionStyle property to Color or Both in order to get the parameter to be set.

Need extra support?

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

Learn More

Forum Channels