选择行中一个DataGridView和具有上行标题后续的箭头 [英] Selecting a row in a DataGridView and having the arrow on the row header follow

查看:145
本文介绍了选择行中一个DataGridView和具有上行标题后续的箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在C#中。如果我在DataGridViewRow.Selected = TRUE一个DataGridView中选择一行,该行选择就好了,但在列标题的箭头(灰色很最左边的列)不遵循。我如何设置?

另一个问题:如果我设置列格式为中心在设计中,列标题仍是左对齐。如何设置栏标题为中心呢?

谢谢, 布莱恩

解决方案

这是直接从<一个href="http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=Selecting+a+row+in+a+DataGridView+and+having+the+arrow+on+the+row+header+follow">google:

在一个DataGridView,选定行和当前行(由所指示的 行标题中的箭头)可能不是在同一行。此外,我们可以 在一个DataGridView选择多行,但当前行只能有一个 行。 当DataGridView中的SelectionMode属性设置为 FullRowSelect,当前行会始终选择。 如果你想改变一个DataGridView控制当前行,你可以 设置CurrentCell属性

  dataGridView1.CurrentCell = dataGridView1.Rows [1] .Cells [0];
 

如果你想只改变所选行,您可以设置选择 你要真该行的财产。

  dataGridView1.CurrentRow.Selected = FALSE;
dataGridView1.Rows [1] .Selected =真;
 

This is in C#. If I select a row in a DataGridView with DataGridViewRow.Selected = true, the row selects just fine, but the arrow in the "column header" (the grey very leftmost column) doesn't follow. How do I set that?

Another question: If I set a column format to "centered" in the designer, the column header is still left aligned. How do I set the column header to be centered too?

Thanks, Brian

解决方案

This is straight from google:

In a DataGridView, the selected row and the current row (indicated by an arrow in the row header) may not be the same row. In addition, we could select multiple rows in a DataGridView but the current row can only be one row. When the SelectionMode property of the DataGridView is set to FullRowSelect, the current row will be always selected. If you'd like to change the current row in a DataGridView control, you may set the CurrentCell property

dataGridView1.CurrentCell = dataGridView1.Rows[1].Cells[0];

If you'd like to just change the selected row, you may set the Selected property of the row you want to true.

dataGridView1.CurrentRow.Selected = false;
dataGridView1.Rows[1].Selected = true;

这篇关于选择行中一个DataGridView和具有上行标题后续的箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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