We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

displaying double data types

Thread ID:

Created:

Updated:

Platform:

Replies:

2239 Dec 23,2002 03:51 PM UTC Dec 24,2002 01:45 PM UTC WinForms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 23, 2002 03:51 PM UTC

Hi , I have a grid bound to a dataset that contains double data types. My celltype is a text box. When I displaying the data if it is 45.0 in the dataset then it gets displayed as 45. However if it is 45.23 it displays correctly. What do i need to change? Thanks in advance

Administrator [Syncfusion]
Replied On December 23, 2002 03:59 PM UTC

You can either force the cell value type to be text by setting Style.CellValueType = typeof(string) or change the format to be something like style.Format = "#.0####" which would force it display at least one digit after the comma. Stefan

Administrator [Syncfusion]
Replied On December 24, 2002 10:54 AM UTC

Here is what i have tried. oGridBoundColumn.StyleInfo.CellValueType = _ GetType(Double) oGridBoundColumn.StyleInfo.Format = "#.0####" I put in both the options that you suggested, but it still does not work. Thanks Jots > > You can either force the cell value type to be text by setting Style.CellValueType = typeof(string) or change the format to be something like style.Format = "#.0####" which would force it display at least one digit after the comma. > > Stefan

Administrator [Syncfusion]
Replied On December 24, 2002 12:55 PM UTC

Are you using version 1.5.1.1? Here is code that I added to a Form_Load event after dropping a GridDataBoundGrid onto the form. With this code, the formatting seemed to work as expected.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As New DataTable("MyTable")

        Dim nCols As Integer = 2
        Dim nRows As Integer = 10

        Dim i As Integer
        Dim j As Integer

        dt.Columns.Add(New DataColumn("Col1"))
        dt.Columns.Add(New DataColumn("doubleCol", GetType(Double)))

        For i = 0 To nRows - 1
            Dim dr As DataRow = dt.NewRow()
            dr(0) = String.Format("row{0}", i)
            dr(1) = 45D
            dt.Rows.Add(dr)
        Next

        Dim column As New GridBoundColumn()
        column.MappingName = "Col1"
        Me.GridDataBoundGrid1.GridBoundColumns.Add(column)

        column = New GridBoundColumn()
        column.MappingName = "doubleCol"
        column.StyleInfo.CellValueType = GetType(Double)
        column.StyleInfo.Format = "#.00"
        Me.GridDataBoundGrid1.GridBoundColumns.Add(column)

        Me.GridDataBoundGrid1.DataSource = dt

End Sub

Administrator [Syncfusion]
Replied On December 24, 2002 01:45 PM UTC

Hi, Thanks a lot, it was a syncfusion version issue, i was running 1.5.0. after upgrading to 1.5.1 it works fine.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;