Datagirdview and tabcontrol issue

后端 未结 1 722
后悔当初
后悔当初 2021-01-14 07:53

I am experiencing a strange behavior in my winforms .net 4 application. I have a form with a tabcontrol having two tabpages, user selects data on tabpage1 and clicks GO butt

相关标签:
1条回答
  • 2021-01-14 08:40

    Instead of doing:

    grdDistProcessing.Rows[0].DefaultCellStyle.BackColor = Color.BurlyWood;
    grdDistProcessing.Rows[0].DefaultCellStyle.ForeColor = Color.Black;
    

    Use the CellFormatting event (Display category) for grdDistProcessing, like this:

    private void grdDistProcessing_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
       e.CellStyle.BackColor = Color.BurlyWood;
       e.CellStyle.ForeColor = Color.Black;
    
    }
    

    It should render faster too.

    0 讨论(0)
提交回复
热议问题