Recent

Author Topic: [SOLVED]advice: Let user change a grids' options without repainting it  (Read 1958 times)

kinlion

  • Jr. Member
  • **
  • Posts: 82
  • I Love Lazarus
I want to draw merged cells with TStringGrid, and write drawing code in a StringGrid's OnDrawCell event. But after calling the event handler, TStringGrid will draw the cell border. That's not my want. Then I remove goHorzLine from the StringGrid's Options in OnDrawCell, unfortunately this maks a dead-loop because after setting the Options, the StringGrid will be fully repainted.

Since FOptions is private of TCustomGrid, I have to add a public procedure to TCusomGrid to modify the Options.

Maybe it's better to let TCustomGrid have a way to modify Options without repaint?
« Last Edit: December 08, 2018, 07:53:05 am by kinlion »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: advice: Let user change a grids' options without repainting it
« Reply #1 on: November 24, 2018, 11:33:00 am »
Did you try to call Grid.BeginUpdate before and Grid.EndUpdate after your changes? They should suppress any redraw requests in between.

kinlion

  • Jr. Member
  • **
  • Posts: 82
  • I Love Lazarus
Re: advice: Let user change a grids' options without repainting it
« Reply #2 on: November 24, 2018, 11:36:54 am »
let me try  :)

kinlion

  • Jr. Member
  • **
  • Posts: 82
  • I Love Lazarus
Re: advice: Let user change a grids' options without repainting it
« Reply #3 on: November 24, 2018, 11:40:29 am »
YES, BeginUpdate/EndUpdate works well.  :D
Thank you very much!
Did you try to call Grid.BeginUpdate before and Grid.EndUpdate after your changes? They should suppress any redraw requests in between.

 

TinyPortal © 2005-2018