C# WinForms DataGridView background color rendering too slow

后端 未结 5 1815
挽巷
挽巷 2021-02-20 14:52

I\'m painting my rows in a DataGridView like this:

private void AdjustColors()
    {            
        foreach (DataGridViewRow row in aufgabenDataGridView.Row         


        
5条回答
  •  长情又很酷
    2021-02-20 15:47

    It's also a good idea to only set the properties if they differ from the expected value. That way you don't trigger unwanted internal DataGridView overhead.

    If all cells in a row are formatted the same way, you can do the formatting on row level instead of cell level.

    DataGridViewCellStyle rowStyle = row.DefaultCellStyle;
    if (rowStyle.BackColor != status.BackColor) { 
       rowStyle.BackColor = status.BackColor;
    }
    

提交回复
热议问题