C#datagridview - 突出显示行(不是选择行),然后在选择列后将其高亮显示 [英] C# datagridview - highlight row (not select row) and then keep it highlight it after selecting column
本文介绍了C#datagridview - 突出显示行(不是选择行),然后在选择列后将其高亮显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我需要一些关于如何在单击列标题后突出显示行(背景色)的建议。
这就是我现在所拥有的:
Hi everyone!
I need some advice on how to keep a row highlighted (backcolor) after a column header is clicked to resort.
This is what I have right now:
foreach (DataGridViewRow dgvr in dataGridView1.Rows)
{
if ((int)dataGridView1.CurrentRow.Cells["KEY"].Value == colorHighlightedRowIndex)
{
dataGridView1.Rows[colorHighlightedRowIndex].DefaultCellStyle.BackColor = Color.Yellow;
}
}
colorhighlightedrowindex应该代表数据库中记录的ID。如何在选择列标题后检查该特定ID?
KEY是表格中的一列。
Google已经过去30分钟没有帮助。
谢谢大家!
colorhighlightedrowindex is supposed to represent an ID of the record in the database. How can I check for that particular ID after a column header is selected?
KEY is a column in the table.
Google has been no help for the last 30 minutes.
Thanks everyone!
推荐答案
你可以通过改变来做到这一点行的默认样式: http://msdn.microsoft.com /en-us/library/system.windows.forms.datagridview.rowsdefaultcellstyle.aspx [ ^ ]。
有关细胞样式和表现的更多信息,请参阅: http://msdn.microsoft.com/en-us/library/1yef90x0.aspx [ ^ ]。
-SA
You can do it by changing the default style of the row: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowsdefaultcellstyle.aspx[^].
For more information on cell styles and presentation, please see: http://msdn.microsoft.com/en-us/library/1yef90x0.aspx[^].
—SA
这篇关于C#datagridview - 突出显示行(不是选择行),然后在选择列后将其高亮显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文