How to disable add new records in datagrid?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • suresh

    How to disable add new records in datagrid?

    frenz,
    i need to disable the add new record mode in datarid.
    i just want to modify the existing records in the
    grid...but i dont want to add new records..how do i do
    that?
    -suresh
  • CJ Taylor

    #2
    Re: How to disable add new records in datagrid?

    Set the grid to read only. Or set every column to read only.

    -CJ
    "suresh" <sureshbabu@pvn etcop.com> wrote in message
    news:048201c383 fe$ee5fe660$a00 1280a@phx.gbl.. .[color=blue]
    > frenz,
    > i need to disable the add new record mode in datarid.
    > i just want to modify the existing records in the
    > grid...but i dont want to add new records..how do i do
    > that?
    > -suresh[/color]


    Comment

    • suresh

      #3
      Re: How to disable add new records in datagrid?

      if i set the grid into read only i coudnt edit the values
      in the column.i just want to edit the column values but i
      dont want to add new records..i just done this by setting
      allownew = false and allowedit = true in the dataview
      object and assign it to the datagrid. its working fine. i
      hope this info will be useful for the future surfers.[color=blue]
      >-----Original Message-----
      >Set the grid to read only. Or set every column to read[/color]
      only.[color=blue]
      >
      >-CJ
      >"suresh" <sureshbabu@pvn etcop.com> wrote in message
      >news:048201c38 3fe$ee5fe660$a0 01280a@phx.gbl. ..[color=green]
      >> frenz,
      >> i need to disable the add new record mode in[/color][/color]
      datarid.[color=blue][color=green]
      >> i just want to modify the existing records in the
      >> grid...but i dont want to add new records..how do i do
      >> that?
      >> -suresh[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: How to disable add new records in datagrid?

        Suresh,
        The VB.NET DataGrid itself does not have an AllowNew property.

        However the DataView object that the DataGrid ultimately gets bound to does
        support an AllowNew property.

        When you bind a DataGrid to a Dataset & table name (or to a DataTable) the
        DataGrid uses the DataTable.Defau ltView property to actually bind to.

        Instead of binding to a DataSet & table name I would recommend binding to a
        DataView. Associate this DataView with your DataTable from your DataSet,
        then set the AllowNew property on this DataView to false. Alternatively you
        may be able to change the DataView returned from DataTable.Defau ltView, but
        remember to change it back when you want to allow adding records...

        DataView is in the System.Data namespace along with DataSet & DataTable.

        Hope this helps
        Jay

        "suresh" <sureshbabu@pvn etcop.com> wrote in message
        news:048201c383 fe$ee5fe660$a00 1280a@phx.gbl.. .[color=blue]
        > frenz,
        > i need to disable the add new record mode in datarid.
        > i just want to modify the existing records in the
        > grid...but i dont want to add new records..how do i do
        > that?
        > -suresh[/color]


        Comment

        Working...