473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Q: Formatting a column in a DataGrid

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
1 909
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff Cook | last post by:
Hi I have a DataGrid that I am using to display a .xml file (that has a schema in a .xsd), like this:- ds.ReadXmlSchema(sDataPath + "Data.xsd"); ds.ReadXml(sDataPath + "Data.xml",...
0
by: Josh Harris | last post by:
Here is my issue: I have a datagrid that is populated with a datatable. I want the columns of the datagrid to be sortable. I also want to format the numeric columns such as two decimal places...
2
by: Evan Brown | last post by:
Hi I have a Datagrid with a boolean column in it. I currently have it set as a textboxColumn and not a checkcolumn. what I want to do is have it say yes/no not true/false. Any suggestions? ...
2
by: coleenholley | last post by:
Hi all :- I have a datagrid which is populated from a class module (we have to do this because of the type connection we use -we DON'T use an SQL Server connection) the code populates the...
1
by: coleenholley | last post by:
I'm getting frustrated with trying to format a datagrid that is entirely populated dynamically using a class module written in VB .Net (No C# used!) We connect to a DB2 database using an RPC that is...
1
by: tfs | last post by:
I am reading into a datagrid and can't seem to get the "execution time" column (the 3rd column) to move to the right. My problem is that the last character in the 2nd column is right up against...
1
by: Michael Calvin | last post by:
Some basic things I cannot figure out how to do with new datagrid. 1) How do I control the formatting of the column header separately from the rest of the column? 2) If I align right the...
1
by: euan | last post by:
HI Guys, I have bee using conditional formatting in the datagrid recently and I am moving over to framework 2.0 and noticed the datagrid has been replaced by the gridview. So, I would like to do...
3
by: daz_oldham | last post by:
I am populating my datagrid 'by hand' by that I mean that i am not using the wizard! What I would like to know, is if I can format my colums - for example if I have a column that is returning...
2
by: =?Utf-8?B?Uml0YUc=?= | last post by:
Hello. I could not find a Web discussion group (only saw Web Services) so am posting my question here. I have a C# Web application that has a form with a datagrid. One of the columns of the data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.