的DataGridView而不在开始选择的行 [英] DataGridView without selected row at the beginning

查看:126
本文介绍了的DataGridView而不在开始选择的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的WinForms我有 DataGridView的。我想一下子让我设置的SelectionMode FullRowSelect 来选择行满。现在我有问题,因为一开始我的表格强调第一行(组选定行是空的,第一行没有选择,但只是强调)。我已经尝试了很多事情,如:

 私人无效dataGridView1_DataBindingComplete(对象发件人,DataGridViewBindingCompleteEventArgs E)
{
dataGridView1.ClearSelection();
}

和所有的失败,因为其实没有选择。



我怎样才能摆脱这种下划线的?

任何帮助!



谢谢类=h2_lin>解决方案

不幸的是没有这些的答案帮助了我,但我发现其他的解决办法。相反,无法选择的,我将只是这段代码隐藏它:

  dataGridView1.DefaultCellStyle.SelectionBackColor = dataGridView1.DefaultCellStyle.BackColor ; 
dataGridView1.DefaultCellStyle.SelectionForeColor = dataGridView1.DefaultCellStyle.ForeColor;



所以,如果有人只是想隐藏选择它会工作得很好。



干杯:)


In my WinForms I have DataGridView. I wanted to select full row at once so I set SelectionMode as FullRowSelect. And now I have problem, because at the beginning my form underlines first row (set of selected rows is empty, the first row is not selected but just underlined). I have tried many things, such as:

    private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
    {
        dataGridView1.ClearSelection();
    }

And all failed, because in fact there is no selection.

How can I get rid of this underline?

Thanks for any help!

解决方案

Unfortunately none of these answers helped me, but I found other solution. Instead of unable selection I will just hide it with this piece of code:

dataGridView1.DefaultCellStyle.SelectionBackColor = dataGridView1.DefaultCellStyle.BackColor;
dataGridView1.DefaultCellStyle.SelectionForeColor = dataGridView1.DefaultCellStyle.ForeColor;

So if anyone just wants to hide the selection it's gonna work pretty well.

Cheers :)

这篇关于的DataGridView而不在开始选择的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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