Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Formatting Cells in a Datagridview

$
0
0

Why can this not be simple?

I have a DataGridView that uses a DataTable as a Datasource.

The datasource contains numbers of different values.

I have a function that looks for the largest precision (digits after the decimal point). I want all of the numbers to be the same length.

3.103

3.100

5.004

How do I make the cells in the DatGridView a fixed format?  

in the following code there are multiple attempts to try to get the formatting, none seem to work... :(

 
 Me.dgv_Array.DataSource = gbl_dsArrayPoints.Tables(Passed_Feature.Name)
        Me.dgv_Array.Font = New Font("Times", 10, FontStyle.Bold)
        Me.dgv_Array.ForeColor = Color.Black
        Dim s_F As String = "N" & Passed_Feature.Precision.ToString
        Dim n_d_F As New DataGridViewCellStyle
        n_d_F.Format = s_F' try to set entire DataGridViewMe.dgv_Array.DefaultCellStyle = New DataGridViewCellStyle(n_d_F)' Try to set ColumnMe.dgv_Array.Columns(0).DefaultCellStyle = n_d_F


	' Try and go back through the grid and set individually.

	For Each c As DataGridViewCell In dgv_Array.Rows(0).Cells
            c.Style.Format = s_F
        Next
        dgv_Array.Refresh()




Man, Im in way over my head!!!


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>