Grid column format

  • Thread starter Sebastian Santacroce
  • 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"
 
K

Ken Tucker [MVP]

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
 
S

Sebastian

Where would I put this code? Before or after I get the
data from the access database?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top