View Full Version : رنگی کردن بعضی از سطرهای گرید
نیما حتمی
سه شنبه 03 اردیبهشت 1392, 18:09 عصر
من یه گرید دارم که 1000 سطر داره میخوام سطرهایی که مقدار سلول 5 مساوی با ok قرمز بشه
چطور این کار رو انجام بدم؟
khokhan
سه شنبه 03 اردیبهشت 1392, 18:28 عصر
من یه گرید دارم که 1000 سطر داره میخوام سطرهایی که مقدار سلول 5 مساوی با ok قرمز بشه
چطور این کار رو انجام بدم؟
سلام
مقداردهی دیتا گریدت در رویداد CellFormatting بایستی یه چیزی شبیه این باشه
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.RowIndex > 0 && e.ColumnIndex == this.dataGridView1.Columns["نوع استخدام"].Index)
{
if (e.Value != null)
{
string RepVisits = e.Value.ToString();
if (RepVisits == "رسمی")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Green;
}
if (RepVisits == "پیمانی")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
}
if (RepVisits == "قراردادی")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Blue;
}
}
}
}
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.