Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hy guys
Thank you for reading and kindly helping me
I wanna edit the value of record in my datagridview.
I use PostgreSQL, and the type of the column of the table is double, so I have change the data type in my datagridview as type double
But I still don't have the clue as type string.

Any idea?

What I have tried:

For i As Integer = 0 To dgv_hasillab.Rows.Count - 1
                  dgv_datapasien.Columns(1).ValueType = GetType(Double)
              Next
Posted
Updated 26-Oct-18 21:57pm

1 solution

Hello,
Add this row in the definition of grid

AddHandler dgv_datapasien.CellFormatting, AddressOf dgv_datapasien_CellFormatting


and then this sub

Private Sub dgv_datapasien_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs)
        If e.ColumnIndex = 1 AndAlso e.RowIndex <> Me.dgv_datapasien.NewRowIndex Then
            Dim d As Double = Double.Parse(e.Value.ToString())
            e.Value = d.ToString("N2")
        End If
    End Sub
 
Share this answer
 
Comments
Member 12544512 31-Oct-18 23:30pm    
Hi. May you both confirm, is above the right solution?
Ahmad Sakr 1-Nov-18 7:33am    
Hi, yes. Did you try it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900