Results 1 to 2 of 2

Thread: how to prevent adding a new record in a datagrid

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2003
    Posts
    20

    how to prevent adding a new record in a datagrid

    I have a datagrid and want to make sure a user only adds a new record through my data entry form to make sure it is verified and correct.

    But is there any way to disable the addition of a new record in the datagrid itself ?

    I had used componentone's truedbgrid on a past job and it had the ability to just set the allowaddnew to false and that would do the trick. Unfortunately I can not afford to purchase that just for a small home project. Besides, I don't have the time to rewrite my app for the new control.

    So, I was wondering if I could just do this with the datagrid included with .net 2003.

    I would like to allow individual records to be change and am using the datagrid's currentcellchanged to do that.

    My grid is bound to an access mdb table using the datasource and datamember.

    Any help will be greatly appreciated.
    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    Here are some code fragments which may help:

    Dim cm As CurrencyManager
    Dim dv1 As DataView
    ds3.Clear()
    da3.Fill(ds3, "BankAccounts")

    DataGrid1.SetDataBinding(ds3, "BankAccounts")
    DataGrid1.DataSource = ds3.Tables("BankAccounts")
    dv1 = ds3.Tables("BankAccounts").DefaultView
    dv1.AllowNew = False
    cm = CType(Me.BindingContext(dv1), CurrencyManager)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width