0

我正在尝试创建一个数据网格视图,它将自动格式化用户输入的数字。我的 datagridview 没有链接到数据源,它是以编程方式构建的,如下所示:

Private Sub FormatGridView()
    Dim ILNumColumn As New DataGridViewTextBoxColumn
    Dim ArtNumColumn As New DataGridViewTextBoxColumn
    Dim DescColumn As New DataGridViewTextBoxColumn

    'Header text
    ILNumColumn.HeaderText = "# IL"
    ArtNumColumn.HeaderText = "# Articles"
    DescColumn.HeaderText = "Description"

    'Wrap
    DescColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True

    'Widths
    ILNumColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
    ArtNumColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
    DescColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill

    'Add columns
    dgvArticles.Columns.Add(ILNumColumn)
    dgvArticles.Columns.Add(ArtNumColumn)
    dgvArticles.Columns.Add(DescColumn)
End Sub

有没有办法让IlNumColumn总是在绿色圆圈下面的格式?

数字格式

4

1 回答 1

0

Number format

'Formatting
ILNumColumn.DefaultCellStyle.Format = "000"

This will make all the numbers in the IlNumColumn in a "001" format.

于 2013-04-29T15:47:13.650 回答