Apend Row in VB.NET Datagrid

J

Joy

Hi,

I need to be able to to disable the Apend Row feature of the VB.NET
datagrid and then enable it again. The reason is because I want to
allow a user to enter as many rows in the datagrid as they want until a
certain number of rows is reached. When that number of rows is reached
I want to disable the Apend Row feature - BUT if they delete a row, I
want to enable the Apend Row feature again. Does that make sense??

I have code that works great to disable the Apend Row feature - but
when I use the same method to enable it again, it doesn't work - it
doesn't produce an error but it just doesn't enable Apend Row feature
again. Here is the code I am using to disable the Apend Row feature:

Dim cm As CurrencyManager = Me.BindingContext(dgTime.DataSource)
CType(cm.List, DataView).AllowNew = False
CType(cm.List, DataView).AllowDelete = True

Here is the code I am using to try to enable it again:

Dim cm As CurrencyManager = Me.BindingContext(dgTime.DataSource)
CType(cm.List, DataView).AllowNew = True
CType(cm.List, DataView).AllowDelete = True

This code does succesfully set CType(cm.List, DataView).AllowNew = True
but the option to type information into a blank row in the datagrid
never appears.

Can anyone help me??

Thanks!

Joy
 
T

Tony

You use two instants, the object is different, try to make one instant.

Dim cm As CurrencyManager = Me.BindingContext(dgTime.DataSource)

and just call this object with new setup, may solve your problem.

Good luck

Tony
 
J

Joy

Let me see if I understand you correctly, are you saying I should
create only one instance of cm, the CurrencyManager??

Joy
 
G

Guest

When are you making the method call? You say that you are using the same
method to enable and disable the new row feature, but from where is the
method being called for
 
J

Joy Labadie

I use the same code I last posted everywhere I need to set the AllowNew,
or AllowDelete properties of the DataView. Perhaps part of the problem
is that I am using it repeatedly in so many places - perhaps I should
just do it in one place - but is that what you are suggesting?

Joy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top