Grid column format

  • Thread starter Thread starter Sebastian Santacroce
  • Start date Start date
S

Sebastian Santacroce

I'm using the code below to change the grid format of a
date fields to use "MMM dd, yyyy" and use a currency
format for the second column but it totaly ignores it.
I've used this method before when using a SQL database and
SQLDataAdapter and it has worked fine. However, the other
thing is different here is that I'm using the
OleDBDataAdapter. Is there some reason that would make a
difference?
How do I get this to work?

Thanks

Dim ts As DataGridTableStyle = New DataGridTableStyle()

Dim DataAdp As OleDbDataAdapter = New
OleDbDataAdapter("GetSales", DBvar)
DataAdp.SelectCommand.CommandType =
CommandType.StoredProcedure
If Not IsDBNull(DataAdp) Then

Try
DataAdp.Fill(ds, "Sales")
Catch ex As Exception
MsgBox(ex.Message,
MsgBoxStyle.Critical, "Error:")
End Try
GrdSales.DataSource = ds.Tables("Sales")
End If

ts.MappingName = ds.Tables("Sales").TableName
GrdSales.TableStyles.Clear()
GrdSales.TableStyles.Add(ts)
ts.AllowSorting = False



Dim wd = ts.GridColumnStyles("Amount")
wd.format = "f"
Dim Col1 = ts.GridColumnStyles("SaleDate")
Col1.width = 160
Col1.format = "MMM dd, yyyy"
 
Hi,

Dim cm As CurrencyManager = CType(Me.BindingContext(ds.Tables("Employees")),
CurrencyManager)

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("BirthDate")

Dim colBDay As New DataGridTextBoxColumn(pd, "MMM dd, yyyy")

With colBDay

..MappingName = "BirthDate"

..HeaderText = "Birth Day"

..Width = 100

End With



Ken
 
Back
Top