@@ -186,7 +186,6 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
186186
187187 int startRow = firstVisibleRow ;
188188 int range = Math . Min ( lastVisibleRow , RowCount - 1 ) - startRow + 1 ;
189- _renderer . PrepDrawString ( Font , _foreColor ) ;
190189
191190 Cell currentCell = new ( ) ;
192191 if ( HorizontalOrientation )
@@ -221,20 +220,17 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
221220 int strOffsetY = 0 ;
222221 QueryItemText ( this , f + startRow , col , out var text , ref strOffsetX , ref strOffsetY ) ;
223222
224- bool rePrep = false ;
225- Color foreColor = _foreColor ;
226- currentCell . Column = col ;
227- currentCell . RowIndex = f + startRow ;
228- if ( _selectedItems . Contains ( currentCell ) )
229- {
230- foreColor = SystemColors . HighlightText ;
231- rePrep = true ;
232- }
233- if ( col . Rotatable || rePrep )
223+ Color ? foreColor = QueryItemForeColor ? . Invoke ( this , f + startRow , col ) ;
224+ if ( foreColor == null )
234225 {
235- _renderer . PrepDrawString ( Font , foreColor , rotate : col . Rotatable ) ;
236- rePrep = true ;
226+ currentCell . Column = col ;
227+ currentCell . RowIndex = f + startRow ;
228+ if ( _selectedItems . Contains ( currentCell ) )
229+ {
230+ foreColor = SystemColors . HighlightText ;
231+ }
237232 }
233+ _renderer . PrepDrawString ( Font , foreColor ?? _foreColor , rotate : col . Rotatable ) ;
238234
239235 int textWidth = ( int ) _renderer . MeasureString ( text , Font ) . Width ;
240236 if ( col . Rotatable )
@@ -253,11 +249,6 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
253249
254250 DrawString ( text , new Rectangle ( baseX + textX , baseY + textY , MaxColumnWidth , CellHeight ) ) ;
255251 }
256-
257- if ( rePrep )
258- {
259- _renderer . PrepDrawString ( Font , _foreColor ) ;
260- }
261252 }
262253 }
263254 }
@@ -285,22 +276,20 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
285276 }
286277
287278 QueryItemText ( this , f + startRow , column , out var text , ref strOffsetX , ref strOffsetY ) ;
279+ Color ? foreColor = QueryItemForeColor ? . Invoke ( this , f + startRow , column ) ;
288280
289- bool rePrep = false ;
290- currentCell . Column = column ;
291- currentCell . RowIndex = f + startRow ;
292- if ( _selectedItems . Contains ( currentCell ) )
281+ if ( foreColor == null )
293282 {
294- _renderer . PrepDrawString ( Font , SystemColors . HighlightText ) ;
295- rePrep = true ;
283+ currentCell . Column = column ;
284+ currentCell . RowIndex = f + startRow ;
285+ if ( _selectedItems . Contains ( currentCell ) )
286+ {
287+ foreColor = SystemColors . HighlightText ;
288+ }
296289 }
297290
291+ _renderer . PrepDrawString ( Font , foreColor ?? _foreColor ) ;
298292 DrawString ( text , new Rectangle ( point . X + strOffsetX , point . Y + strOffsetY , column . Width , ColumnHeight ) ) ;
299-
300- if ( rePrep )
301- {
302- _renderer . PrepDrawString ( Font , _foreColor ) ;
303- }
304293 }
305294 }
306295 }
0 commit comments