all groups > dotnet windows forms databinding > april 2007 >
You're in the

dotnet windows forms databinding

group:

Binding navigator button states


Binding navigator button states Rick
4/17/2007 8:26:34 AM
dotnet windows forms databinding:
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

Re: Binding navigator button states Daniel E. Ulfe
4/17/2007 10:54:59 AM
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.

[quoted text, click to view]

Re: Binding navigator button states Rick
4/17/2007 11:37:45 AM
Yes, thats what I wanted. Thanks Daniel

[quoted text, click to view]

Re: Binding navigator button states Rick
4/17/2007 4:52:49 PM
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

[quoted text, click to view]

AddThis Social Bookmark Button