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

CellElement null

1 Answer 202 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Konrad Radinger
Top achievements
Rank 1
Konrad Radinger asked on 15 May 2010, 10:49 PM
Hi,

I have problems with VS2010 and the newest Version with the GridView. I can't set the Font and other properties, because the CellElement is null. The same code works with VS2008 and the GridView from the last year.

Is that a known problem?

Greetings

Konrad


 

 

private void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)

 

{

...
...

e.RowElement.GradientStyle =

 

GradientStyles.Solid;

 

e.RowElement.RowInfo.Cells[

 

"Nr"].CellElement.Font = _einzelRingFontNr;

 

e.RowElement.RowInfo.Cells[

 

"Ring"].CellElement.Font = _einzelRingFontRing;

 

e.RowElement.RowInfo.Cells[

 

"Teiler"].CellElement.Font = _einzelRingFontTeiler;

 

e.RowElement.RowInfo.Cells[

 

"Pos"].CellElement.Font = _einzelRingFontPosition;

 

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 19 May 2010, 03:29 PM
Hi Konrad Radinger,

You should not try to access cell elements by using the RowInfo collection when handling CellFormatting and RowFormatting events. The best option is to format cells when handling CellFormatting event. I changed your code a bit:

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridViewDataColumn column = e.CellElement.ColumnInfo as GridViewDataColumn;
    if (column != null)
    {
        switch (column.UniqueName)
        {
            case "Nr": e.CellElement.Font = _einzelRingFontNr; break;
            case "Ring": e.CellElement.Font = _einzelRingFontRing; break;
            case "Teiler": e.CellElement.Font = _einzelRingFontTeiler; break;
            case "Pos": e.CellElement.Font = _einzelRingFontPosition; break;
            default:
                e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
                break;
        }
    }
}

I hope this helps.

Regards,
Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Konrad Radinger
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or