Hello,
Having some problems with the radgridview.
In the CellFormatting event i add some backgroundcolors and a progressbar to the grid.
All works fine here.
But when I collapse and expand the groups in the grid. The progressbar is moving up and down a copple a rows ( not corresponding with the data in the rows).
Any suggestions?
Kind regards,
Tim van Rooijen
private void radGridViewProductie_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
// exclude header element in the data column
if (e.CellElement.ColumnInfo is GridViewDataColumn && !(e.CellElement.RowElement is GridTableHeaderRowElement))
{
GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo;
GridViewRowInfo gvri = e.CellElement.RowInfo;
if (gvri != null)
{
SchrapView Sv = (SchrapView)gvri.DataBoundItem;
if (Sv != null)
{
//Voor percentage velden worden weergegeven met een progressbar
if (column.FieldName == "VorigeBewerking.PercentageCompleet" || column.FieldName == "Nacalculatie.PercentageCompleet")
{
// check if the progress bar is already added to the cell
if (e.CellElement.Children.Count > 0)
return;
RadProgressBarElement element = new RadProgressBarElement();
e.CellElement.Children.Add(element);
element.StretchHorizontally = true;
element.StretchVertically = true;
// extract the value in the cell, convert it to a value
// usable in the progress bar element and assign it to the
// progress bar Value1 and Text properties
int discountPercentage = Convert.ToInt32(e.CellElement.Text);
if (discountPercentage > 100)
{
element.Value1 = 100;
}
else
{
element.Value1 = discountPercentage;
}
element.Text = discountPercentage.ToString() + "%";
}
if (column.FieldName == "Indicator")
{
if (!Sv.AchterGrondKleur.IsEmpty)
{
e.CellElement.BackColor = Sv.AchterGrondKleur;
e.CellElement.DrawFill = true;
}
else
{
e.CellElement.BackColor = Color.Transparent;
e.CellElement.BackColor2 = Color.Transparent;
e.CellElement.DrawFill = true;
}
}
}
}