本文介绍了[Que] datagridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

datagridView.RowsDefaultCellStyle. SelectionFont(?)不存在..

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

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

如何使选定行的字体变为粗体?

推荐答案

 

字体_fnt =新字体("Arial",12,FontStyle.Bold);

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


dataGridView1.RowsDefaultCellStyle.Font = _fnt;


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.


 

 字体_DefaultFont = new Font("Arial",10,FontStyle.Regular);
      私有void dataGridView1_CellClick(对象发送者,DataGridViewCellEventArgs e)
       {
                    
           Int32 _SelectedRowIndex = dataGridView1.CurrentRow.Index;
Font _fnt = new Font("Arial",12,FontStyle.Bold);
          DataGridViewRow _selectedRow = dataGridView1.SelectedRows [0];
          _selectedRow.DefaultCellStyle.Font = _fnt;

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

 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;
                }
            }
        }


这篇关于[Que] datagridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:12