473,221 Members | 1,934 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,221 software developers and data experts.

Datagrids -> Custom Table and Column Styles???

Hi,

I am having a few problems with my datagrid, the data in my database isn't
coming through right. for example 100.00 in the table is coming through as
100 and 01/01/2004 in the table is coming through as 01/01/2004 10:45 AM???
how do i format my custom table and column styles to reflect the correct
data type stored in my tables... my code is as follows.

// Add a GridTableStyle and set the MappingName

// to the name of the DataTable.

DataGridTableStyle TSGLBatch = new DataGridTableStyle() ;

TSGLBatch.MappingName = "tblGLBatch" ;

try {

// Add a GridColumnStyle and set the MappingName

// to the name of a DataColumn in the DataTable.

// Set the HeaderText and Width properties.

DataGridColumnStyle TCTransNum = new DataGridTextBoxColumn() ;

TCTransNum.MappingName = "TransNum" ;

TCTransNum.HeaderText = "Trans Number" ;

TCTransNum.Width = 65 ;

TSGLBatch.GridColumnStyles.Add(TCTransNum) ;

DataGridColumnStyle TCCode = new DataGridTextBoxColumn() ;

TCCode.MappingName = "Code" ;

TCCode.HeaderText = "Chart Code" ;

TCCode.Width = 65 ;

TSGLBatch.GridColumnStyles.Add(TCCode) ;

DataGridColumnStyle TCReference = new DataGridTextBoxColumn() ;

TCReference.MappingName = "Reference" ;

TCReference.HeaderText = "Reference" ;

TCReference.Width = 65 ;

TSGLBatch.GridColumnStyles.Add(TCReference) ;

DataGridColumnStyle TCTDate = new DataGridTextBoxColumn() ;

TCTDate.MappingName = "TDate" ;

TCTDate.HeaderText = "Date" ;

TCTDate.Width = 75 ;

TSGLBatch.GridColumnStyles.Add(TCTDate) ;

DataGridColumnStyle TCAmount = new DataGridTextBoxColumn() ;

TCAmount.MappingName = "Amount" ;

TCAmount.HeaderText = "Amount" ;

TCAmount.Width = 65 ;

TSGLBatch.GridColumnStyles.Add(TCAmount) ;

TSGLBatch.AllowSorting = false ;

dgGLBatch.TableStyles.Add(TSGLBatch) ;

}

catch(Exception e) {

MessageBox.Show(e.Message, "AddCustomDataTableStyle", MessageBoxButtons.OK,
MessageBoxIcon.Error) ;

}


Regards

Darryn
Nov 16 '05 #1
3 1418
hi,
i got your issue. So i think you know datagridstyle class. right. Now your
issue is individula column formatting.

See your code.

DataGridColumnStyle TCTransNum = new DataGridTextBoxColumn() ;

TCTransNum.MappingName = "TransNum" ;

TCTransNum.HeaderText = "Trans Number" ;

TCTransNum.Width = 65 ;

here you can set one more property that will deside in which format you can
show the content of that cell.

TCTransNum.Format="c" >>> this mean you want to show the content in
currency format which is complient to your culture info.

Like this you can show the content in different format.
If you have MSDN in your machine then please try to type the link that i
mention just below. There you will get lot of format froms. And how you need
to use that.
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconcustomdatetimeformatstrings.htm
Please type this link in your VS.NET IDE help Url entry box.
Nov 16 '05 #2
i don't have the "Format" property listed against my DataGridColumnStyle ??
is there something i am not doing right?
"Sreejith S S Nair" <Sr************@discussions.microsoft.com> wrote in
message news:EE**********************************@microsof t.com...
hi,
i got your issue. So i think you know datagridstyle class. right. Now your issue is individula column formatting.

See your code.

DataGridColumnStyle TCTransNum = new DataGridTextBoxColumn() ;

TCTransNum.MappingName = "TransNum" ;

TCTransNum.HeaderText = "Trans Number" ;

TCTransNum.Width = 65 ;

here you can set one more property that will deside in which format you can show the content of that cell.

TCTransNum.Format="c" >>> this mean you want to show the content in
currency format which is complient to your culture info.

Like this you can show the content in different format.
If you have MSDN in your machine then please try to type the link that i
mention just below. There you will get lot of format froms. And how you need to use that.
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconcustomdatet
imeformatstrings.htm

Please type this link in your VS.NET IDE help Url entry box.

Nov 16 '05 #3
Format is a property of the DataGridTextBoxColumn class

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
"Darryn Ross" <da****@datawave.com.au> wrote in message
news:eS**************@TK2MSFTNGP11.phx.gbl...
i don't have the "Format" property listed against my DataGridColumnStyle ?? is there something i am not doing right?
"Sreejith S S Nair" <Sr************@discussions.microsoft.com> wrote in
message news:EE**********************************@microsof t.com...
hi,
i got your issue. So i think you know datagridstyle class. right. Now your
issue is individula column formatting.

See your code.

DataGridColumnStyle TCTransNum = new DataGridTextBoxColumn() ;

TCTransNum.MappingName = "TransNum" ;

TCTransNum.HeaderText = "Trans Number" ;

TCTransNum.Width = 65 ;

here you can set one more property that will deside in which format you

can
show the content of that cell.

TCTransNum.Format="c" >>> this mean you want to show the content in
currency format which is complient to your culture info.

Like this you can show the content in different format.
If you have MSDN in your machine then please try to type the link that i
mention just below. There you will get lot of format froms. And how you

need
to use that.

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconcustomdatet imeformatstrings.htm


Please type this link in your VS.NET IDE help Url entry box.


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
In SQL Server Query Analyzer, if I type in, say, 2 select queries, it returns 2 datagrids of results, with a scrollbar on the right to scroll between the 2 (or more) datagrids. I wanted to...
2
by: Marcel | last post by:
Hi, I'm new to VS and ASP.NET and have a question about master/detail datagrids. I have a master datagrid filled with data via a component that contains a SQL adapter. Now I would like to fill...
9
by: | last post by:
I have a web page written in asp.net that has multiple datagrids on it that would need to be exported to Excel. Each of the datagrids would be a subset of what the datagrid above it was. Thus...
4
by: mark | last post by:
i have datagrids set out as such on a webform with vb behind datagrid1 datagrid2 datagrid3 datagrid4 datagrid5 datagrid6 datagrid7
1
by: Simon Harris | last post by:
Hi All, I wish to populate more than one datagrid from the same OleDBCommand. The code I have is: Dim objCmd As New OleDbCommand(strSql, objConn) Then... ...
4
by: ree32 | last post by:
I have a placeholder and depending on a user input(a drop downlist) when the user clicks a button I dynamically create a number of datagrids and fill them with data from a database. But the problem...
0
by: Scott Meddows | last post by:
I'm having trouble scrolling some datagrids so they sync up... I have two identical datagrids on a form, filled with eh same dataset. I want a user to be able to scroll on the datasets and the...
4
by: | last post by:
Hello. In SQL Server Query Analyzer, if I type in, say, 2 select queries, it returns 2 datagrids of results, with a scrollbar on the right to scroll between the 2 (or more) datagrids. I wanted to...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
1
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, I am using the code below to export a webpage to Excel. The webpage has three datagrids on it and they are all exported to Excel properly and everything looks very nice, but we would really...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.