DataGrid column width.

Please visit this : Samsung Service Galaxy S

I recently found out that the datagrid component doesn`t have the column property. The smartdevice project doesn`t have DataGridView in the toolbox, so you would have to work with the DataGrid componnent.

[All code below is in C#]
At first you must create a DataGridTableStyle :

DataGridTableStyle ts = new DataGridTableStyle();

ts.MappingName = “”;

ts.GridColumnStyles.Clear();
If you have a DataTable to use as a datasource for the grid :

DataTable t = getProduse();

Now if you have to create DataGridColumnStyles for each column in the datatable:

for (int i = 0; i < t.Columns.Count; i++)

{

DataGridColumnStyle Col = new DataGridTextBoxColumn();

Col.MappingName = t.Columns[i].ColumnName;

Col.HeaderText = t.Columns[i].ColumnName;

Col.Width = 400;

ts.GridColumnStyles.Add(Col);

}

After this you add the DataGridTableStyle to the DataGrid:
dataGrid1.TableStyles.Add(ts);
Now when you select the DataSource the grid will have the Style you want:
dataGrid1.DataSource = t;

Commerce Server 2009
By Ing. Msc. Dan Gheorghe

Advertisements