By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

Grid column format

P: n/a
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"

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

--------------------------

"Sebastian Santacroce" <se*******@ilogic.com> wrote in message
news:2e*****************************@phx.gbl...
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"

Nov 20 '05 #2

P: n/a
Where would I put this code? Before or after I get the
data from the access database?
-----Original Message-----
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

--------------------------

"Sebastian Santacroce" <se*******@ilogic.com> wrote in messagenews:2e*****************************@phx.gbl...
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"

.

Nov 20 '05 #3

P: n/a
Hi,

http://msdn.microsoft.com/library/de...asicprimer.asp

Ken
------------------
"Sebastian" <se*******@ilogic.com> wrote in message
news:2f*****************************@phx.gbl...
Where would I put this code? Before or after I get the
data from the access database?
-----Original Message-----
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

--------------------------

"Sebastian Santacroce" <se*******@ilogic.com> wrote in messagenews:2e*****************************@phx.gbl...
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"

.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.