Grid CellFormatting

6 posts, 0 answers
  1. Erik
    Erik avatar
    80 posts
    Member since:
    Jul 2007

    Posted 27 Sep 2007 Link to this post

    Hi, Telerik team

    I hereby drop an issue that need Telerik Team to help.
    I have a coding to differentiate the format of a row with other row of a column

    for example:
    stock  FOCTYPE  FOC
    A          FOC          1
    B          AMT        $1

    i am using vb

    my coding are:
    dim Cols as GridViewDataColumn

    the below coding is placed into CellFormating event of the Grid

    if e.CellElement.ColumnInfo.UniqueName = "FOC" then
        TheType = e.CellElement.Value
        if TheType = "AMT" then
            Cols = new GridViewDataColumn("FOC")
            Cols.DataTextFormatString = "{0:c}"
        end if
    end if

    My question: Are the listed coding correct? because i never get the result i expected. The format for FOCTYPE = "AMT" still 1 instead of $1

    Telerik Team's help is appreciated

    Thanks in advance


  2. Erik
    Erik avatar
    80 posts
    Member since:
    Jul 2007

    Posted 03 Oct 2007 Link to this post

    So,

    Any solution for this?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Tobin
    Tobin avatar
    9 posts
    Member since:
    Oct 2007

    Posted 05 Oct 2007 Link to this post

    Hi Telerik, I am just using the telerik Q2, i found the same problem as erik does. Please help.

    Help is deeply appreciated
  5. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 08 Oct 2007 Link to this post

    In this code just a new GridViewDataColumn is created, but it is never used. The right way to apply text formatting to GridCellElement is to set its FormatString property. Here is the code:

        Private Sub RadGridView1_CellFormatting(ByVal sender As System.ObjectByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting 
            Dim column As Telerik.WinControls.UI.GridViewDataColumn 
            If TypeOf e.CellElement.ColumnInfo Is Telerik.WinControls.UI.GridViewDataColumn Then 
                column = CType(e.CellElement.ColumnInfo, Telerik.WinControls.UI.GridViewDataColumn) 
                If column.DataField = "FOC" And e.CellElement.RowInfo.Cells("FOCTYPE").Value = "AMT" Then 
                    column.DataTextFormatString = "{0:c}" 
                    e.CellElement.FormatString = "{0:c}" 
                End If 
            End If 
        End Sub 

    The format string does not work because probably you are using a GridViewTextBoxColumn and all values are converted to string. We will research this issue and will provide a solution in our next release, if needed.

     
    Regards,
    Jack
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. piratenwichtl
    piratenwichtl avatar
    18 posts
    Member since:
    Aug 2007

    Posted 09 Oct 2007 Link to this post

    Hi,
    i got a decimal value in my dataset and I try to display it with 3 digits..
    like
    #.##

    I played around with the format quite a bit yet but I am not able to get it displayed as intended..... both with gridviewtextboxcolumn and decimalcolumn.
    before I waste any more time, could you please give me a hint?

    thanks in advance
    t
  7. Tobin
    Tobin avatar
    9 posts
    Member since:
    Oct 2007

    Posted 10 Oct 2007 Link to this post

    This formatting issues has been discussed in this forum.

    you can read this article http://www.telerik.com/community/forums/thread/b311D-hcabb.aspx

    the formatting should be place into DataTextFormatString of the properties : MasterGridView --> column

Back to Top
UI for WinForms is Visual Studio 2017 Ready