gpt4 book ai didi

c# - 在 DataGridView 中选择一行并跟随行标题上的箭头

转载 作者:可可西里 更新时间:2023-11-01 03:13:54 27 4
gpt4 key购买 nike

这是在 C# 中。如果我在 DataGridViewRow.Selected = true 的 DataGridView 中选择一行,该行选择得很好,但“列标题”(最左边的灰色列)中的箭头不会跟随。我该如何设置?

另一个问题:如果我在设计器中将列格式设置为“居中”,列标题仍然左对齐。如何将列标题也设置为居中?

谢谢,布莱恩

最佳答案

这直接来自 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;

关于c# - 在 DataGridView 中选择一行并跟随行标题上的箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1135304/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com