Click here to Skip to main content
15,908,274 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

datagridView.RowsDefaultCellStyle.SelectionForeColor = Color.Navy
datagridView.RowsDefaultCellStyle.SelectionBackColor = Color.WhiteSmoke

datagridView.RowsDefaultCellStyle.SelectionFont(?) is not exist..

How to make bold font of a selected row?

Posted
Updated 23-Nov-09 21:19pm
v4

Try this

 

Font _fnt = new Font("Arial",12,FontStyle.Bold);


dataGridView1.RowsDefaultCellStyle.Font = _fnt;

 

Ahhh no wait...that can't be right.

 

That will change for all the cells.

 

Let me put that on a form and see what it does.

 
Share this answer
 
v2

Okay this is not going to be the best way  of doing it but it does work.

 

 Font _DefaultFont = new Font("Arial", 10, FontStyle.Regular);
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
           
            Int32 _SelectedRowIndex = dataGridView1.CurrentRow.Index;
            Font _fnt = new Font("Arial", 12, FontStyle.Bold);
           DataGridViewRow _selectedRow = dataGridView1.SelectedRows[0];
            _selectedRow.DefaultCellStyle.Font = _fnt;

            for (Int16 _i = 0; _i < dataGridView1.Rows.Count; _i++)
            {
                if (_i != Convert.ToInt16(_SelectedRowIndex))
                {
                    DataGridViewRow _Row = dataGridView1.Rows[_i];
                    _Row.DefaultCellStyle.Font = _DefaultFont;
                }
            }
        }

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900