SHINHAN
SHINHAN

Reputation: 735

How to format a column in datagrid control?

I got this problem trying to format the values of a specific column but gives me error Object doesn't support this property of method. How can I fix this issue?

Here is my code:

Set dgData.DataSource = rs
dgData.Columns(1).DataFormat = "#,##0.00"

Upvotes: 1

Views: 4685

Answers (3)

Alan
Alan

Reputation: 1

Set dgData.DataSource = rs dgData.Columns(1).NumberFormat = "#,##0.00"

Upvotes: 0

Mery
Mery

Reputation: 11

use NumberFormat instead of DataFormat.

Upvotes: 1

King of kings
King of kings

Reputation: 695

Try this code

Dim d As Integer
For i as Integer = 0 to dgData.Rows.Count -1
     d = CInt(dgData.Rows(i).Cells(1).ToString
     d.ToString("#,##0.00")
     dgData.Rows(i).Cells(1).Value = d
Next

Upvotes: 1

Related Questions