Code is below Ollie;
public void LoadGridData(System.Data.DataView dvData)
{
dvData.AllowNew = false;
dvData.AllowEdit = false;
dvData.AllowDelete = false;
this.dgStockMasterSummary.ColumnHeadersVisible = false;
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "DVSummary";
DataGridTextBoxColumn textboxColStyle = null;
for(int i = 0; i<dvData.Table.Columns.Count; i++)
{
switch(dvData.Table.Columns
.ColumnName)
{
case "Manufacturer":
textboxColStyle = new DataGridTextBoxColumn();
textboxColStyle.HeaderText = "Manufacturer";
textboxColStyle.MappingName = dvData.Table.Columns.ColumnName;
tableStyle.GridColumnStyles.Add(textboxColStyle);
textboxColStyle.Width = 128;
textboxColStyle.WidthChanged +=new
EventHandler(textboxColStyle_WidthChanged);
break;
case "Product Line":
textboxColStyle = new DataGridTextBoxColumn();
textboxColStyle.HeaderText = "Product Line";
textboxColStyle.Width = 178;
textboxColStyle.MappingName = dvData.Table.Columns.ColumnName;
tableStyle.GridColumnStyles.Add(textboxColStyle);
break;
case "Mill Name":
textboxColStyle = new DataGridTextBoxColumn();
textboxColStyle.HeaderText = "Mill Name";
textboxColStyle.Width = 177;
textboxColStyle.MappingName = dvData.Table.Columns.ColumnName;
tableStyle.GridColumnStyles.Add(textboxColStyle);
break;
case "Cost":
textboxColStyle = new DataGridTextBoxColumn();
textboxColStyle.HeaderText = "Cost";
textboxColStyle.Format = "C";
textboxColStyle.Alignment =
System.Windows.Forms.HorizontalAlignment.Right;
textboxColStyle.Width = 115;
textboxColStyle.MappingName = dvData.Table.Columns.ColumnName;
tableStyle.GridColumnStyles.Add(textboxColStyle);
break;
case "C&C Price":
textboxColStyle = new DataGridTextBoxColumn();
textboxColStyle.Format = "C";
textboxColStyle.Alignment =
System.Windows.Forms.HorizontalAlignment.Right;
textboxColStyle.Width = 115;
textboxColStyle.HeaderText = "C&C Price";
textboxColStyle.MappingName = dvData.Table.Columns.ColumnName;
tableStyle.GridColumnStyles.Add(textboxColStyle);
break;
case "Price":
textboxColStyle = new DataGridTextBoxColumn();
textboxColStyle.HeaderText = "Price";
textboxColStyle.Format = "C";
textboxColStyle.Alignment =
System.Windows.Forms.HorizontalAlignment.Right;
textboxColStyle.Width = 115;
textboxColStyle.MappingName = dvData.Table.Columns.ColumnName;
tableStyle.GridColumnStyles.Add(textboxColStyle);
break;
}
}
this.dgStockMasterSummary.TableStyles.Clear();
this.dgStockMasterSummary.TableStyles.Add(tableStyle);
this.dgStockMasterSummary.RowHeadersVisible = false;
//this.dgStockMasterSummary.RowHeaderWidth = 10;
this.dgStockMasterSummary.DataSource = dvData;
}
Ollie Riches said:
It should work fine can you post the example code?
HTH
Ollie Riches
Hi,
I am trying to hide the datagrid row header (the left most column that
has the 'select' triangle in it which moves with the selected row). It
seems to be fairly simple; this.dgStockMasterSummary.RowHeadersVisible
= false;
however it doesn't hide it. Hiding the column headers works just fine.
Does anyone have any ideas?
Tim