Home Forums WPF controls Xceed DataGrid for WPF If cell contains a numerical value how to round up ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • kaptan
    Participant
    Post count: 8
    #43955 |

    Hi to all,

    I’m using Xceed Datagrid for WPF (v.3.9) with the development platform VB 2008 (C#).

    Currently I have the following problem:

    If a cell contains a numerical value how to round up ?

    For example the following data is coming from the DB:
    Example

    I want to get the average from the result so I use the AverageFunction. The AverageFunchtion works but the result is very long “1,816666666”, so how can I round up the result to “1,82” ???
    In my example (see picture) the result from AVG is only in Footer Resources.Add(“tableViewFixedFooter3.

    This is how I user the average Function :

    
    if (xStatCells.Attribute("statKind").Value.ToString() == "avg")
    { 
      dGCV.StatFunctions.Add(new AverageFunction("avgOf" + strFieldName, strFieldName));
                                                    
    }
    

    I would be happy if someone can help me.
    Thank you

    kaptan
    Participant
    Post count: 8

    Someone who can help me with that problem ???? Any Help would be appreciate.

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    In order to achieve this you may assign the desired format to the StatCell’s ContentStringFormat. A simple code snippet which can be used to display two figures after the comma would be:

    <xcdg:StatRow>
    <xcdg:StatCell FieldName=”Date” ContentStringFormat=”{}{0:C2}” />
    </xcdg:StatRow>

    kaptan
    Participant
    Post count: 8

    Thank you very much. I will try this out.

    kaptan
    Participant
    Post count: 8

    Fawzi, thank you for your help, it works 🙂

    Do you or someone know how I can configure the result to left/right/middle justified ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.