D
Darryn Ross
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
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