Windows Develop Bookmark and Share   
 index > Windows Forms General > problem in datagrid view Back Color C# 2005
 

problem in datagrid view Back Color C# 2005

i had some process in datagridview and changed some backcolor on each row and displayed that color, but i click on the datagridview Header, all backcolor is gone. If any properties to change to give me an idea .net 2005
  • Moved byeryangMSFTFriday, September 25, 2009 1:26 AM (From:.NET Base Class Library)
  •  
Kartheechidambaram  Thursday, September 24, 2009 1:12 PM
no solution for this... or after sorting re-coloring.. thats very slow in many rows.I use third part datagridview - xceed grid.
Lucifer L.  Saturday, September 26, 2009 7:56 PM

Hi Kartheechidambaram,

We need to reset the color of the rows in the ColumnHeaderMouseClick event handler. This is a code snippet:

    private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        //Reset the row color.
        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            if(IsSetYellow(row))
                row.DefaultCellStyle.BackColor = Color.Yellow;
        }
    }
    private bool IsSetYellow(DataGridViewRow view)
    {
        //Write code here to check and return if the row needs to be colored.
        return true;
    }


Regards,
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Monday, September 28, 2009 5:19 AM
no solution for this... or after sorting re-coloring.. thats very slow in many rows.I use third part datagridview - xceed grid.
Lucifer L.  Saturday, September 26, 2009 7:56 PM

Hi Kartheechidambaram,

We need to reset the color of the rows in the ColumnHeaderMouseClick event handler. This is a code snippet:

    private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        //Reset the row color.
        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            if(IsSetYellow(row))
                row.DefaultCellStyle.BackColor = Color.Yellow;
        }
    }
    private bool IsSetYellow(DataGridViewRow view)
    {
        //Write code here to check and return if the row needs to be colored.
        return true;
    }


Regards,
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Monday, September 28, 2009 5:19 AM

You can use google to search for other answers

Custom Search

More Threads

• Why using childForm.MDIParent = this not show childForm
• Not everything loading up on execution?
• string encoding expert help needed
• Faster control rendering
• MDI child is removed from window list when cancelling a FormClosed event
• Move a 2D Sprite in Direction
• custom mp3 player help
• Expanding treenodes without selecting
• TreeView fun facts
• Raising Refresh_button_click from child form