-
October 5th, 2009, 09:16 PM
#1
Hide the true value of datagridview cell
I just want to ask guys if there is a property of datagridview that will automatically formats the value of each cell but it will go back into original value before the user edits its data. This is only applicable for double datatype.
example. the value of the cell is 12908.21232311. But the datagrid will show only 12908.2123.
And when the user edits the cell, the 12908.2123 will go back to its original form 12908.21232311. And when the user changed the value of 12908.21232311 into
12908.44444444, it will format again into 4 decimal places which is 12908.4444
Thanks guys
-
October 5th, 2009, 10:47 PM
#2
Re: Hide the true value of datagridview cell
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.DataGridView1.Rows.Add(123.22222, 33333.3221)
End Sub
Private Sub DataGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles DataGridView1.CellBeginEdit
Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.Format = Nothing
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.Format = "N2"
End Sub
but the problem is when I finished edited the value, it will not format the cell in 2 decimal places.
-
October 6th, 2009, 02:15 AM
#3
Re: Hide the true value of datagridview cell
Something like this:
Code:
DataGridView1.Columns(3).HeaderText = "Payment (Total: " + FormatCurrency(totalsum(3)).ToString & ")"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|