PDA

View Full Version : عدم رنگ زنی سطرهای DataGridview



hadimtn
دوشنبه 26 بهمن 1394, 04:53 صبح
سلام...
با استفاده از متد زیر سطرهای DataGridView رو یکی در میان رنگ میکنم اما برای بار اول اجرا (Form_Load) رنگ زنی انجام نمیشه!


public static void DataGridViewColoring(DataGridView d)
{
int X = 1;
foreach (DataGridViewRow dr in d.Rows)
{
if (X % 2 == 0)
{
dr.DefaultCellStyle.BackColor = Color.Beige;
}
else
{
dr.DefaultCellStyle.BackColor = Color.Bisque;
}
X++;
}
}

vB.N3T
دوشنبه 26 بهمن 1394, 07:37 صبح
توی فرم لود اینو بنویس

foreach (DataGridViewRow row in dataGridView1.Rows)

if (row.Index % 2 == 0)
{
row.DefaultCellStyle.BackColor = Color.Gainsboro;
}

AmiN0012
دوشنبه 26 بهمن 1394, 07:43 صبح
دوست عزیز دیتاگرید خاصیت AlternatingRowsDefualtCellStyle قسمت backcolor این کارو خودش میکنه براتون.نیاز به متد نیست