R
Rich
I have working sample code demonstrating the use of DataGridTableStyle,
but for some reason it's not working for me. The column headings just
assume the field names instead of the "HeaderText" I specify and any
other properties I set are ignored. Any ideas?
Code:
SqlCeConnection cn = new SqlCeConnection(@"Data Source=\My
Documents\Databases\EquipCert.sdf");
string sql = "select entry_id, step_name from tblCertData ";
SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(sql, cn);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
dgData.DataSource = dataSet.Tables[0];
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "tblCertData";
DataGridColumnStyle entryId = new DataGridTextBoxColumn();
entryId.MappingName = "entry_id";
entryId.HeaderText = "";
entryId.Width = 0;
ts.GridColumnStyles.Add(entryId);
DataGridColumnStyle step = new DataGridTextBoxColumn();
step.MappingName = "step_name";
step.HeaderText = "Step";
step.Width = 50;
ts.GridColumnStyles.Add(step);
dgData.TableStyles.Add(ts);
Thank you.
but for some reason it's not working for me. The column headings just
assume the field names instead of the "HeaderText" I specify and any
other properties I set are ignored. Any ideas?
Code:
SqlCeConnection cn = new SqlCeConnection(@"Data Source=\My
Documents\Databases\EquipCert.sdf");
string sql = "select entry_id, step_name from tblCertData ";
SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(sql, cn);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
dgData.DataSource = dataSet.Tables[0];
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "tblCertData";
DataGridColumnStyle entryId = new DataGridTextBoxColumn();
entryId.MappingName = "entry_id";
entryId.HeaderText = "";
entryId.Width = 0;
ts.GridColumnStyles.Add(entryId);
DataGridColumnStyle step = new DataGridTextBoxColumn();
step.MappingName = "step_name";
step.HeaderText = "Step";
step.Width = 50;
ts.GridColumnStyles.Add(step);
dgData.TableStyles.Add(ts);
Thank you.