Binding navigator button states

R

Rick

VS 2005

The short version:
How can I set the enabled state of a button depending on if a
strongly-typed datatable has a DeleteCommand?

***************************

The long version:

I have a windows form with a binding navigator.

There are various strongly-types datatables used throughout the form
attached to controls.

In the navigator RefreshItems event I am setting various buttons enabled
states. I have a problem with the delete button which I am setting like
this:

navigator.btnDelete.enabled = navigator.bindingSource.AllowRemove

But this always evaluates to TRUE regardless is the underlying bindingsource
datatable has an adapter.DeleteCommand, i.e. its not possible to delete.

So I tried to do the same from a dataview.

Dim dv as DataView = New DataView(myTable)
navigator.btnDelete.enabled = dv.AllowDelete

But this also evaluates to TRUE.

What do I need to test to see if the underlying datatable will allow a
delete?

Rick
 
D

Daniel E. Ulfe

Do you want to check if you have enough database level permission to delete
a record?...

If you only want to check if your DataTable has a DeleteCommand... you can
check if for "nothing"... like:

myDeleteButton.Enable = Not myDataTable.DeleteCommand is Nothing

Hope this helps...

Daniel.
 
R

Rick

Yes, thats what I wanted. Thanks Daniel

Daniel E. Ulfe said:
Do you want to check if you have enough database level permission to
delete a record?...

If you only want to check if your DataTable has a DeleteCommand... you can
check if for "nothing"... like:

myDeleteButton.Enable = Not myDataTable.DeleteCommand is Nothing

Hope this helps...

Daniel.
 
R

Rick

I spoke too quickly before.

DeleteCommand is a field of DataAdapter not DateTable so it has no
application here unless I am missing something.

AFAIK a the dataadapter on my form has no backwards relationship with the
datatable it originally came from so I can't cast from here either.

Anyone else?

Rick
 

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