C#datagridview设置某一行的边框颜色
时间: 2023-09-13 13:10:20 浏览: 55
C#中改变DataGridView控件边框颜色的方法
要设置C# DataGridView中某一行的边框颜色,可以使用DataGridView的RowPrePaint事件来实现。以下是一个示例代码:
```csharp
private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
var dataGridView = (DataGridView)sender;
var row = dataGridView.Rows[e.RowIndex];
var borderColor = Color.Red; // 设置边框颜色
using (var pen = new Pen(borderColor))
{
var bounds = new Rectangle(e.RowBounds.Left, e.RowBounds.Top,
e.RowBounds.Width - 1,***
阅读全文