Tables wihout addition of new lines

  • Thread starter Thread starter Stephan
  • Start date Start date
S

Stephan

Hi there,

I am trying to show a table with C# where the User cannot
add new lines. And, it should also not be possible to
change the width of the rows. Tried everything, this
makes me crazy!
Is there a possibility to link dataGrids directly to just
normal Arrays or must I use these weired DataTable,
DataColumn, DataView etc?
Or, can I call e. g. Excel from inside my program?

Thanks for answers or ideas,

Stephan
 
Hi Stephan,

To prevent the user from adding new rows, do the following after you've
bound the grid to the table:

CurrencyManager cm = (CurrencyManager)this.BindingContext[grid.DataSource,
grid.DataMember];
DataView view = (DataView)cm.List;

view.AllowNew = false;

You can also use arrays of objects with the grid, in this mode the grid
won't display the "Add new" row.

As for resizing the columns, if there's no such a property on the grid,
you'll have to tap into mouse handling and prevent standard functionality
when the user clicks between the column headers and drags.
 
Back
Top