removing row selector from datagrid

  • Thread starter Ockert Vermeulen
  • Start date
O

Ockert Vermeulen

Hi guys

I would like to hide the row selector (grey column on left) and the add new
row at the bottom of the datagrid.

Dows anyone know how to do this?

Regards
Okkie
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Ockert,

To hide the row selector, you should reset a property called
RowHeadersVisible (or something similar, please check with MSDN or at least
IntelliSense or Object Browser) to false. This property is available either
for the DataGrid control itself, or for the DataGridTableStyle instance
corresponding to a data table the data grid displays.

Hiding the "add new" row is little bit trickier. If you bind the datagrid to
a DataView, just set its AllowNew property to false. But if you bind the
datagrid to a datatable, do the following:

1. Obtain a reference to a CurrencyManager instance:

CurrencyManager cm = dataGrid.BindingContext[dataGrid.DataSource,
dataGrid.DataMember];

2. Obtain a reference to a DataView created by the datagrid for the
datatable:

DataView theView = (DataView)cm.List;

3. Set the DataView's AllowNew property to false.
 

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

Top