نوشته شده توسط
NasimBamdad
برای گرید Telerik جواب نمیده متاسفانه
Cannot convert type 'Telerik.WinControls.UI.GridViewRowInfo' to 'System.Windows.Forms.DataGridViewRow'
'System.Windows.Forms.DataGridViewRow' does not contain a definition for 'Style' and no extension method 'Style' accepting a first argument of type 'System.Windows.Forms.DataGridViewRow' could be found (are you missing a using directive or an assembly reference?)
کنترلradGridView کامپوننت Telerik ، یه رویداد داره به نام ViewRowFormatting که می تونین ردیف یا سلول خاصی رو بر اساس شرط خاصی رنگ آمیزی کنی
void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
{
Console.WriteLine(e.RowElement.GetType());
if (e.RowElement is GridTableHeaderRowElement)
{
e.RowElement.DrawFill = true;
e.RowElement.BackColor = Color.Navy;
e.RowElement.NumberOfColors = 1;
e.RowElement.ForeColor = Color.White;
}
else
{
e.RowElement.ResetValue(LightVisualElement.DrawFil lProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.BackCol orProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.NumberO fColorsProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.ForeCol orProperty, ValueResetFlags.Local);
}
}
ویا اینکه در رویداد RowFormatting بنویسین اینطوری :
private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
if ((bool)e.RowElement.RowInfo.Cells["BMP"].Value == true)
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = GradientStyles.Solid;
e.RowElement.BackColor = Color.Aqua;
}
else
{
e.RowElement.ResetValue(LightVisualElement.BackCol orProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.Gradien tStyleProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.DrawFil lProperty, ValueResetFlags.Local);
}
}