petre ricardo

petre ricardo

  • NA
  • 194
  • 0

How do i align a Data Grid View column withe column of a DataTable?

Mar 15 2010 12:49 AM

Hi friend,

at form load its' requiremewnt that i should display the Structure of the DataGridView columns as:
Photobucket
I ahve designed teh following datatable:
 
DataTable
dtProposedMaterials = new DataTable("dtPropMaterials");

dtProposedMaterials.Columns.Add(
"Code", typeof(string));
dtProposedMaterials.Columns.Add(
"Material Type", typeof(string));
dtProposedMaterials.Columns.Add(
"Material Name", typeof(string));
dtProposedMaterials.Columns.Add(
"Amount Required", typeof(decimal));

 
dtProposedMaterials.Rows.Add(
"MKL001", "MTYP01", "Zinc", "10.23");
dtProposedMaterials.Rows.Add(
"MKL002", "MTXP04", "Copper", "0.89");
dtProposedMaterials.Rows.Add(
"MKL003", "MTCP05", "Aluminum", "1.23");
dtProposedMaterials.Rows.Add(
"MKL004", "MTTG07", "Magnesium", "11.23");

 When i Assign the DataGridVIew control with the created table, it diplays like this: 
>Photobucket
as you can it doesnt display the data in the proper columns instead it display the data in the to the right side by creating identical duplicate columns.

But i dont want it to dsiplay data like that, i want it to remove adding duplicate columns of the right side and add all the data to the orginal columns of the left side... HOw do i do this?

thanks 

Answers (7)