removing row selector from datagrid

  • Thread starter Thread starter Ockert Vermeulen
  • Start date 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
 
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.
 
Back
Top