Hide Datagrid Row Header...?

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

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
 
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;

}
 
You haven't set the RowHeadersVisible property on the TableStyle to be false
:)

tableStyle.RowHeadersVisible = false;

HTH

Ollie Riches


Tim said:
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
 
Thank you Ollie, that was it!

Tim

Ollie Riches said:
You haven't set the RowHeadersVisible property on the TableStyle to be
false :)

tableStyle.RowHeadersVisible = false;

HTH

Ollie Riches


Tim said:
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

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top