How do I stop new rows

I want a datagrid with 4 rows only and one column editable.

I've loaded the data, and figured out how to allow one column only to be editable (by setting other columns to readonly.

Problem is, how do I stop the user from inserting new rows

Setting grid to readonly stops editing of column


Answer this question

How do I stop new rows

  • daniel qi

    Hi,
     Bound ur Grid with Datatable.Dataview as

    pi_dtTable.DefaultView.AllowNew = False

                dgData.DataSource = pi_dtTable .DefaultView

    Hope this will help u...........

    Reagrds,
    Ritesh

  • Oroborus

    You do not necessarily need to change the DataSource:

    Dim CM as currencymanager = ctype(me.bindingcontext(dgchild.datasource,dgchild.datamember),currencymanager 

    ctype(cm.list,dataview).allownew = false 


    This way you are not changing the DataSource but you still set the AllowNew as False.

    I fo this advice from "jfuentes"  for a question I asked.

  • sdsachs

    Hej,

    Set the datagrid's datasource to a dataview instead of a datatable

    Dim Dataview1 as new Dataview

    Dataview1.table = 'Name of Datatable'
    Dataview1.allownew = False
    Datagrid.datasource = Dataview1

    That should do it for you.

    Regards

    Finn

  • How do I stop new rows