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

Changing "0.00" into "" - Removing Zero Values

2 Answers 385 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SMCRadUser
Top achievements
Rank 1
SMCRadUser asked on 30 Apr 2012, 01:17 PM
Good Morning Telerik Community,

I am attempting to format certain cells in my RadGridView to remove the text from a cell if its value == 0.0 ... It works but for what ever reason it is Very slow and takes about two seconds to continue... Am I doing something wrong?

Note: The extension method String.ToDecimal() attempts to convert the string to a decimal and returns a decimal?, null if it failed. I've replaced it with a standard Convert.ToDecimal() and it made no difference..

        private Boolean CellFormatting { get; set; }
  
        private void gridGLDetails_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
        {
  
            if (!CellFormatting && (e.Column.HeaderText == "Credit" || e.Column.HeaderText == "Debit") && e.CellElement.Text.ToDecimal() == 0.0M)
            {
                CellFormatting = true;
                e.CellElement.Text = "";
                CellFormatting = false;
            }
  
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 30 Apr 2012, 02:14 PM
Hello, 

Unless I've misunderstood your request, this should work for you. 

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.RowIndex > -1 && e.Column.Name == "Credit")
    {
        if (Convert.ToDecimal(e.CellElement.Value) == 0)
        {
            e.CellElement.Text = "";
        }
    }
}

Hope that helps
Richard
0
Stefan
Telerik team
answered on 03 May 2012, 01:08 PM
Hello,

I have marked Richard's post as an answer. Please let us know whether this works for you.
 
Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
SMCRadUser
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or