Live Chat Icon For mobile
Live Chat Icon

How can I change the width of the row headers or hide them

Platform: WinForms| Category: Datagrid

You can get at the width and visibility of the header row/column through a DataGridTableStyle. DataGridTableStyle has properties such as RowHeadersVisible and RowHeadersWidth. DataGridTableStyle also controls things like selections colors and GridLine styles.

// Create a table style that will hold the new column style 
// that we set and also tie it to our customer’s table from our DB
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = 'customers';

//hide the column headers
tableStyle.ColumnHeadersVisible = false;

//change width of the row headers
tableStyle.RowHeadersWidth = 100;
   
// make the dataGrid use our new tablestyle and bind it to our table
dataGrid1.TableStyles.Clear();

dataGrid1.TableStyles.Add(tableStyle);

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.