WinForm DataGridView控件隔行變色的小例子
更新時間:2013年03月18日 21:31:57 作者:
WinForm的DataGridView控件設(shè)置行的顏色
復(fù)制代碼 代碼如下:
dgv.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.White;
隔行變色
復(fù)制代碼 代碼如下:
/// <summary>
/// 隔行變色
/// </summary>
/// <param name="dgv">傳入DataGridView控件名稱</param>
public static void DgvRowColor(System.Windows.Forms.DataGridView dgv)
{
if (dgv.Rows.Count != 0)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
if ((i + 1) % 2 == 0)
{
dgv.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.White;
}
else
{
dgv.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(224, 254, 254);
}
}
}
}
您可能感興趣的文章:
- C#開發(fā)WinForm根據(jù)條件改變DataGridView行顏色
- WinForm使用DataGridView實現(xiàn)類似Excel表格的查找替換功能
- C#開發(fā)WinForm之DataGridView開發(fā)詳解
- Winform讓DataGridView左側(cè)顯示圖片
- Winform在DataGridView中顯示圖片
- WinForm中DataGridView折疊控件【超好看】
- winform用datagridview制作課程表實例
- WinForm中DataGridView添加,刪除,修改操作具體方法
- C#開發(fā)WinForm清空DataGridView控件綁定的數(shù)據(jù)
相關(guān)文章
C#使用iTextSharp設(shè)置PDF所有頁面背景圖功能實例
這篇文章主要介紹了C#使用iTextSharp設(shè)置PDF所有頁面背景圖功能,實例分析了C#使用iTextSharp設(shè)置PDF頁面背景圖的實現(xiàn)方法,具有一定參考借鑒價值,需要的朋友可以參考下2015-07-07UnityShader使用Plane實現(xiàn)翻書效果
這篇文章主要為大家詳細(xì)介紹了UnityShader使用Plane實現(xiàn)翻書效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-07-07C#中ManualResetEvent實現(xiàn)線程的暫停與恢復(fù)
本文主要介紹了C#中ManualResetEvent實現(xiàn)線程的暫停與恢復(fù),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-01-01