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

Q: Formatting a column in a DataGrid

P: n/a
Hi

In a problem that was kindly solved for me in this newsgroup I had a table
which I was displaying in a DataGrid. One column had date and time. When
displayed in the grid it showed only the date part. I wanted the time to be
displayed. I was told I could do this by using the following code:

Dim aColumn1 As New DataGridTextBoxColumn
Dim aColumn2 As New DataGridTextBoxColumn

etc.

With aColumn1
.MappingName = "Col1"
.HeaderText = "Col1"
.Width = 50
End With

etc.

The column with the date/time has .Format set to the correct type to
display.

Finally, we use

With aGridStyle.GridColumnStyles
.Add(aColumn1)
etc.
End With

DataGrid1.TableStyles(aGridStyle)

As I say, the method works BUT what if the table I have has 100 columns?
Then using this method I have to create 100 DataGridTextBoxColumn objects
and then just add a format command to one of them.

I suspect there is an easier way to do it. As I say, all I need to do is to
change the format of one of the columns. Is there a way of doing this
without doing all the "unnecessary" work?

Thanks in advance guys

Geoff
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

http://www.syncfusion.com/FAQ/WinFor...c44c.asp#q973q
Ken
-------------------------
"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi

In a problem that was kindly solved for me in this newsgroup I had a table
which I was displaying in a DataGrid. One column had date and time. When
displayed in the grid it showed only the date part. I wanted the time to
be
displayed. I was told I could do this by using the following code:

Dim aColumn1 As New DataGridTextBoxColumn
Dim aColumn2 As New DataGridTextBoxColumn

etc.

With aColumn1
.MappingName = "Col1"
.HeaderText = "Col1"
.Width = 50
End With

etc.

The column with the date/time has .Format set to the correct type to
display.

Finally, we use

With aGridStyle.GridColumnStyles
.Add(aColumn1)
etc.
End With

DataGrid1.TableStyles(aGridStyle)

As I say, the method works BUT what if the table I have has 100 columns?
Then using this method I have to create 100 DataGridTextBoxColumn objects
and then just add a format command to one of them.

I suspect there is an easier way to do it. As I say, all I need to do is
to
change the format of one of the columns. Is there a way of doing this
without doing all the "unnecessary" work?

Thanks in advance guys

Geoff

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.