[Que] datagridView [英] [Que] datagridView

查看:114
本文介绍了[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.


好的,这不是最好的方法

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

 

 字体_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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆