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

Manipulate Data Formats within cells

4 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeremy Pryor
Top achievements
Rank 1
Jeremy Pryor asked on 21 Dec 2009, 11:16 PM
How would I change the font weight and color of the values in a particular cell based on a caculcation between 2 other cells.  For instance, when Accounts Receivable is less than Accounts Payable (both are grid columns) how would I format the Total revenue column so that the values in them are Red and bold and when the opposite is true, then how would I format it to bold and black?

4 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 22 Dec 2009, 10:11 AM
Hi Jeremy Pryor,

You should use CellFormatting event in this case. Please check your previous forum post for more detail - 268627. Should you have other questions, don't hesitate to ask.

Regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jeremy Pryor
Top achievements
Rank 1
answered on 28 Dec 2009, 05:39 PM
I have tried to access the CellFormatting event in the radGridView, but I am unable to see it as a valid event for the control.  Please see my attached screenshot.

Thanks,

Jeremy
0
Robert
Top achievements
Rank 1
answered on 28 Dec 2009, 09:54 PM
Hello Jeremy,

In looking at the screenshot you've posted, it looks like you are using the RadControls for Silverlight. Am I correct in assuming this? This forum is actually for the RadControls for WinForms. The RadGridView for Silverlight has an API very different from the RadGridView for WinForms. You can find the GridView for Silverlight forum here. I apologize for any confusion this may have caused.

This forum post in the Silverlight forum might be similar to what you are looking for:

For any WinForms control users that run across this post, here is how you can set up cell formatting to do what Jeremy has described:
        private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) 
        { 
            // Total Revenue Formatting 
            if (e.CellElement.ColumnIndex == 2) 
            { 
                // accounts receivable > accounts payable 
                if (((int)e.CellElement.RowElement.RowInfo.Cells[0].Value) > ((int)e.CellElement.RowElement.RowInfo.Cells[1].Value)) 
                { 
                    e.CellElement.ForeColor = Color.Red; 
                    e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold); 
                } 
                else // accounts receivable < accounts payable 
                { 
                    e.CellElement.ForeColor = Color.Black; 
                    e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold); 
                } 
            } 
        } 

Thanks,
Robert
0
Jeremy Pryor
Top achievements
Rank 1
answered on 28 Dec 2009, 10:54 PM
Jack,

Thank you for the help.  I apologize for posting this in the incorrect forum. 
Tags
GridView
Asked by
Jeremy Pryor
Top achievements
Rank 1
Answers by
Jack
Telerik team
Jeremy Pryor
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Share this question
or