Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
foreach(DataGridColumnStyle vColumnStyle in myGrid.TableStyles[0].GridColumnStyles )
{
if (vColumnStyle.HeaderText.ToLower()=="mycolumn")
{
//vColumnStyle.HeaderText = "";
//vColumnStyle.MappingName = "";
//vColumnStyle.Alignment = System.Windows.Forms.HorizontalAlignment.Center ;
vColumnStyle.Width = 60;
}
}
DataTable dt = new DataTable();
workingDataAdapter.FillSchema(dt, SchemaType.Source);
workingDataAdapter.Fill(dt);
dataGrid1.TableStyles.Clear();
DataGridTableStyle vStyle = new DataGridTableStyle();
foreach(DataColumn vColumn in dt.Columns)
{
if (vColumn.DataType.ToString().ToLower()=="system.string")
{
DataGridTextColumn vColumnStyle= new DataGridTextColumn();
vColumnStyle.AllowNull = false;
vColumnStyle.HeaderText = vColumn.ColumnName;
vColumnStyle.MappingName = vColumn.ColumnName ;
//vColumnStyle.Alignment = System.Windows.Forms.HorizontalAlignment.Center ;
vColumnStyle.Width = vColumn.MaxLength;
vStyle.GridColumnStyles.Add(vColumnStyle);
}
if (vColumn.DataType.ToString().ToLower() == "system.datetime")
{
//..
}
if (vColumn.DataType.ToString().ToLower() == "system.decimal")
{
//..
}
if (vColumn.DataType.ToString().ToLower() == "system.boolean") // checkbox
{
DataGridBoolColumn vColumnStyle= new DataGridBoolColumn();
vColumnStyle.Alignment = System.Windows.Forms.HorizontalAlignment.Center ;
vColumnStyle.Width = 10;
vStyle.GridColumnStyles.Add(vColumnStyle);
}
}
dataGrid1.TableStyles.Add(vStyle);
dataGrid1.SetDataBinding(dt);