Changing Datagridview Row Color RRS feed

  • Question

  • Hello,

           I have  an windows form application developed in C#.Net. It contains a datagridview.

         I have an option to configure to change background color, font, fore ground color etc. for an single selected row in the Datagrid(currently we disabled multiselect property). I am using DefaultCellStyle.SelectionBackColor and DefaultCellStyle.SelectionForeColor to change the color of selected row.

       We got a new requirement in this, I would like to enable multi select property in such a way that different selected rows should highlight with different color, font etc.

     Eg: I would like to highlight Row 1 and Row 5 with different color and font. In this case how can I accomplish this task.

    Thanks in Advance

    Santosh Kumar Potnuru

    • Edited by Santosh541 Tuesday, June 19, 2018 5:59 AM
    Monday, June 18, 2018 9:19 AM

All replies

  • Hi Santosh,

    Try this:

            private void dataGridView1_SelectionChanged(object sender, EventArgs e)
                dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Red;



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, June 19, 2018 2:11 AM