@@ -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 Cell mouseCell = null ;
@@ -226,28 +225,21 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
226225 int strOffsetY = 0 ;
227226 QueryItemText ( this , f + startRow , col , out var text , ref strOffsetX , ref strOffsetY ) ;
228227
229- bool rePrep = false ;
230- Color foreColor = _foreColor ;
228+ Color ? foreColor = QueryItemForeColor ? . Invoke ( this , f + startRow , col ) ;
231229 Font font = Font ;
232230 currentCell . Column = col ;
233231 currentCell . RowIndex = f + startRow ;
234- if ( _selectedItems . Contains ( currentCell ) )
232+ if ( foreColor == null && _selectedItems . Contains ( currentCell ) )
235233 {
236234 foreColor = SystemColors . HighlightText ;
237- rePrep = true ;
238235 }
239236 if ( string . IsNullOrEmpty ( text ) && mouseCell == currentCell )
240237 {
241238 font = new Font ( Font , FontStyle . Regular ) ;
242239 foreColor = SystemColors . GrayText ;
243240 text = col . Text ;
244- rePrep = true ;
245- }
246- if ( col . Rotatable || rePrep )
247- {
248- _renderer . PrepDrawString ( font , foreColor , rotate : col . Rotatable ) ;
249- rePrep = true ;
250241 }
242+ _renderer . PrepDrawString ( font , foreColor ?? _foreColor , rotate : col . Rotatable ) ;
251243
252244 int textWidth = ( int ) _renderer . MeasureString ( text , font ) . Width ;
253245 if ( col . Rotatable )
@@ -266,11 +258,6 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
266258
267259 DrawString ( text , new Rectangle ( baseX + textX , baseY + textY , MaxColumnWidth , CellHeight ) ) ;
268260 }
269-
270- if ( rePrep )
271- {
272- _renderer . PrepDrawString ( Font , _foreColor ) ;
273- }
274261 }
275262 }
276263 }
@@ -299,34 +286,23 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
299286
300287 QueryItemText ( this , f + startRow , column , out var text , ref strOffsetX , ref strOffsetY ) ;
301288
302- bool rePrep = false ;
303- Color foreColor = _foreColor ;
289+ Color ? foreColor = QueryItemForeColor ? . Invoke ( this , f + startRow , column ) ;
304290 Font font = Font ;
305291 currentCell . Column = column ;
306292 currentCell . RowIndex = f + startRow ;
307- if ( _selectedItems . Contains ( currentCell ) )
293+ if ( foreColor == null && _selectedItems . Contains ( currentCell ) )
308294 {
309295 foreColor = SystemColors . HighlightText ;
310- rePrep = true ;
311296 }
312297 if ( string . IsNullOrEmpty ( text ) && mouseCell == currentCell )
313298 {
314299 font = new Font ( Font , FontStyle . Regular ) ;
315300 foreColor = SystemColors . GrayText ;
316301 text = column . Text ;
317- rePrep = true ;
318- }
319- if ( rePrep )
320- {
321- _renderer . PrepDrawString ( font , foreColor ) ;
322302 }
323303
304+ _renderer . PrepDrawString ( font , foreColor ?? _foreColor ) ;
324305 DrawString ( text , new Rectangle ( point . X + strOffsetX , point . Y + strOffsetY , column . Width , ColumnHeight ) ) ;
325-
326- if ( rePrep )
327- {
328- _renderer . PrepDrawString ( Font , _foreColor ) ;
329- }
330306 }
331307 }
332308 }
0 commit comments