I am trying to apply a column style to the table (dtTasks) that is displayed in a grid. I don’t think that it has applied as no matter what size I make the first column width it remains the same. The code I am using is as follows:
All help appreciated Thx T.
Age is a consequence of experience
Code:
System.Windows.Forms.DataGridTableStyle TableStyle1 = new DataGridTableStyle();
TableStyle1.MappingName = "Tasktable";
int j=0;
//for(; j<dtTasks.Columns.Count; j++)
//{
DataGridColumnStyle taskNameStyleCol = new DataGridTextBoxColumn();
taskNameStyleCol.MappingName = "cs" + dtTasks.Columns[j].ColumnName;
taskNameStyleCol.Width = 200;
taskNameStyleCol.HeaderText = dtTasks.Columns[j].Caption; //dc.Caption;
taskNameStyleCol.Alignment = System.Windows.Forms.HorizontalAlignment.Left ;
taskNameStyleCol.ReadOnly = false;
temp = dtTasks.Columns[j].ColumnName;
TableStyle1.GridColumnStyles.Add(taskNameStyleCol);
dgTask.AlternatingBackColor = Color.Gainsboro;
dgTask.TableStyles.Add(TableStyle1);
dgTask.DataSource = dtTasks;
Age is a consequence of experience