473,385 Members | 1,983 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,385 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 1426
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
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.