PDA

View Full Version : تغییر رنگ سطر گرید تلریک



@liReza11800
شنبه 05 اردیبهشت 1394, 12:12 عصر
سلام دوستان
من یک گرید تلریک دارم که به بانک وصله
یکی از فیلدهای گرید با نام RowClolor مقدار argb توش ذخیره شده
حالا من میخوام هر سطر گرید به رنگ اشاره شده در سطر خودش در بیاد
چی کار کنم ؟
کمکم کنید خیلی فوریه

Todco.ir
شنبه 05 اردیبهشت 1394, 13:13 عصر
از این کد استفاده کن دوست عزیز:
string str_color;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
str_color = dataGridView1.Rows[i].Cells[3].Value.ToString();
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.FromName(str_color);
}

مقدار داخل cells را بسته یه شماره فیلد جدول خود تغییر دهید.

@liReza11800
شنبه 05 اردیبهشت 1394, 14:32 عصر
دوست عزیز این کد برای تلریک کار نمیکنه

khokhan
شنبه 05 اردیبهشت 1394, 14:52 عصر
سلام دوستان
من یک گرید تلریک دارم که به بانک وصله
یکی از فیلدهای گرید با نام RowClolor مقدار argb توش ذخیره شده
حالا من میخوام هر سطر گرید به رنگ اشاره شده در سطر خودش در بیاد
چی کار کنم ؟
کمکم کنید خیلی فوریه

.................................................. .............................


void radGridView1_CellFormatting2(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if (e.CellElement.ColumnInfo.HeaderText == "Id")
{
if (e.CellElement.RowInfo.Cells["Mahyat"].Value != null)
{
if ((string)e.CellElement.RowInfo.Cells["Mahyat"].Value == "بستانکار")
{
e.CellElement.DrawFill = true;
e.CellElement.ForeColor = Color.Blue;
e.CellElement.NumberOfColors = 1;
e.CellElement.BackColor = Color.Aqua;
}
else
{
e.CellElement.DrawFill = true;
e.CellElement.ForeColor = Color.Yellow;
e.CellElement.NumberOfColors = 1;
e.CellElement.BackColor = Color.Green;
}
}
}