DataGridView changing cell background color

后端 未结 10 1690
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 10:20

I have the following code :

private void dgvStatus_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
    foreach (DataGridViewRow          


        
10条回答
  •  盖世英雄少女心
    2020-11-30 10:56

    If you are still intrested in why this didn't work for you at first:

    The reason you don't see changes you've made to the cell's style is because you do these changes before the form was shown, and so they are disregarded.

    Changing cell styles in the events suggested here will do the job, but they are called multiple times causing your style changes to happen more times than you wish, and so aren't very efficient.

    To solve this, either change the style after the point in your code in which the form is shown, or subscribe to the Shown event, and place your changes there (this is event is called significantly less than the other events suggested).

提交回复
热议问题