468,512 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

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 1302
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by | last post: by
2 posts views Thread by Marcel | last post: by
9 posts views Thread by | last post: by
4 posts views Thread by mark | last post: by
1 post views Thread by Simon Harris | last post: by
7 posts views Thread by Ausclad | last post: by
1 post views Thread by =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.