Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset help - no Addnew but edit allowed? 1

Status
Not open for further replies.

Coxylaad

Programmer
Jan 27, 2004
155
0
0
GB
Hi all,
I am trying to remove the add new record line at the bottom of my dataset but retain the ability to edit existing records.

in MS Access it would go something like:

datagrid1.allowadditions = false
datagrid1.allowedits = true

the only thing I can find in vb.net is
tablestyle.readonly = true

which locks both. Can anyone help me out please?

thanks

Ian
 
The DataView that is used by the grid to display data does have an AllowNew property. To access it you can use the following:
Code:
Dim cm As CurrencyManager = CType(DataGrid1.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember), CurrencyManager)

CType(cm.List, DataView).AllowNew = False
This prevents the AddNew row being shown, but still allows edits.
 
Thank you very much - I have been stuck on that for donkeys!

Have a star :)

Ian
 
I have discovered a bit of a snag with this.

I have the datagrid setup as a child list which is driven by its parent. When I change the parent value the child list changes but the addnew row reappears.

I have tried inserting the code to remove the addnew at the end of the selectedindex changed on the parent list box, but it seems that the relating data in the datagrid only changes when the SelectedIndexCode has finished running.

so does anyone know how to

a)Put a break in the code to allow the child fields to update, then allow me to remove the addnew row after?

b)does anyone know of a specific event which is AfterSelectedIndexChanged?

Thanks for your time.

ian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top