This is a migrated thread and some comments may be shown as answers.

WinForms 2008Q2

1 Answer 38 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 15 Sep 2008, 08:25 AM
The code example off the manual is incorrect regarding custom cell formatting.

The problem is that with the documentation example the progressbar gets drawn at wrong postitions (especially when scrolling the grid vertically) in the correct column, the original value gets drawn also (instead of the progressbar) and last but not least, the progressbar gets drawer gray instead of green (randomly).

The working code is : 

//Don't do anything if there is no column info, or the cel is a Header element of the data column.

if ((e.CellElement.ColumnInfo is GridViewDataColumn) && (e.CellElement.RowElement is GridTableHeaderRowElement) == false)

{

GridViewDataColumn columnInfo = (GridViewDataColumn)e.CellElement.ColumnInfo;

if (columnInfo.FieldName == "SurfaceConsumedTotalInPct") //For all the cells that match the databound property's name.

{

e.CellElement.Children.Clear();

RadProgressBarElement progressBar = new RadProgressBarElement();

e.CellElement.Children.Add(progressBar);

double intValue = (double)e.CellElement.RowInfo.Cells["columnSurfaceConsumedTotalInPct"].Value;

progressBar.Value1 = (

int)Math.Round(intValue, 0);

if (intValue > 0)

{

//only show the % textually in the progressbar if there is a value greater than zero,

progressBar.Text = intValue.ToString() +

"%";

}

else

{

progressBar.Text =

string.Empty;

}

// apply theme to the progress bar

progressBar.SeparatorWidth = 0;

//ApplyThemeToElement(progressBar, this.radGridViewWarehouseOccupations.ThemeName);

ApplyThemeToElement(progressBar,

null);

}

}

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 15 Sep 2008, 01:03 PM
Hi Jack,

Thank you for your questions.

I cannot reproduce the issue, however I noticed that you use different strings for the databound property name (SurfaceConsumedTotalInPct and columnSurfaceConsumedTotalInPct) which is unrelated to the issues you are experiencing. Therefore, please open a new support ticket and send us a sample project which we can analyze.

For your reference, I am attaching a sample project to demonstrate the topic in the manual.
I am looking forward to your response.

 
All the best,

Nick
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Jack
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or