DataGrid Column Format Ignored

tfowler

Regular
Joined
Aug 16, 2005
Messages
84
Location
Columbus, OH
I am using a DataGrid to display data while it is being acquired from a rack of instruments. It works fine except that it seems to ignore the column formats that I have specified. I want to display my measurement with a fixed 5 decimal places, so I did the following:

Visual Basic:
Dim tbcDataAcquisition As New DataGridTextBoxColumn
With tbcDataAcquisition
    .HeaderText = "Measurement"
    .Width = 75
    .MappingName = "measurement"
    .Format = "F5"
End With
GridTableStyle.GridColumnStyles.Add(tbcDataAcquisition)

I then add this style to my DataGrid in the Form.Load statement:

Visual Basic:
dgDataAcquisition.TableStyles.Add(oStep.GridTableStyle)
oStep.GridTableStyle.MappingName = "test_data"

The header text, and width are formatted properly, but the data format is not. Anyone have any idea what is going on? I read somewhere that you need to add the style to the DataGrid after filling it with data...is this true? If so, this won't work for me...since I want to display the data as it is acquired. Any suggestions?

By the way, it is not entirely clear on what they expect in the Format field, so I also tried:

Visual Basic:
.Format = "{0:F5}"

and

Visual Basic:
.Format = "0.00000"

and

Visual Basic:
.Format = "{0:0.00000}"

It ignores everything.

Thanks for your help,

Todd
 
Last edited:
Back
Top