displaying double data types
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
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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.
SIGN IN To post a reply.
- 4 Replies
- 1 Participant
-
AD Administrator
- Dec 23, 2002 03:51 PM UTC
- Dec 24, 2002 01:45 PM UTC