رنگی کردن سطرهای دیتاگرید ویو
کد:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.dataGridView1.Rows.Add(new object[] { 1,2,3});
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
this.dataGridView1.Rows.Add(new object[] { 1, 2, 3 });
for (int counter = 0; counter < this.dataGridView1.Rows.Count; counter++)
{
if (counter % 2 == 0)
{
this.dataGridView1.Rows[counter].DefaultCellStyle.BackColor = Color.LightGray;
}
}
}
}
}