473,378 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Binding navigator button states

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
Apr 17 '07 #1
3 2771
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.

"Rick" <Ri**@LakeValleySeed.comwrote in message
news:eR**************@TK2MSFTNGP05.phx.gbl...
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

Apr 17 '07 #2
Yes, thats what I wanted. Thanks Daniel

"Daniel E. Ulfe" <du***@buhlelectric.comwrote in message
news:uF**************@TK2MSFTNGP03.phx.gbl...
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.

"Rick" <Ri**@LakeValleySeed.comwrote in message
news:eR**************@TK2MSFTNGP05.phx.gbl...
>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


Apr 17 '07 #3
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

"Daniel E. Ulfe" <du***@buhlelectric.comwrote in message
news:uF**************@TK2MSFTNGP03.phx.gbl...
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.

"Rick" <Ri**@LakeValleySeed.comwrote in message
news:eR**************@TK2MSFTNGP05.phx.gbl...
>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


Apr 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
0
by: Mike | last post by:
I wasn't real sure which was the best group for this post - please feel free to redirect to the appropriate group(s). My form uses a binding navigator to move through my data source (imagine...
1
by: ankz | last post by:
Hi Guys I have got 3 tables - in Access Database with Student ID as primary Key in all and all tables are linked with 1 to 1 relationship. I have code the everying with manual program to...
0
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I am dragging a data souce (access.mdb) to a form. C# automaticallt creates the table adapter, binding adapter, etc. But for some reason, it is not automatically creating the binding navigator. Any...
2
by: Randy | last post by:
Hi, I'd like to add a new blank record to a form for the user to input data. What I am trying to do is exactly what the + on the binding navigator does, with some additional steps involved. So,...
2
by: Randy | last post by:
Hi, I'm trying to figure out some binding navigator code. If I have the primary field value as selected by the user in a combo box, how can I instruct the binding navigator to move to that...
1
by: GS | last post by:
the windows form application works but the eventhandler for binding source postionChanged got executed too many times: 12 times from saveitemclicked for the data navigator many time from additem ...
1
by: qazplm114477 | last post by:
hello, I have notice that when i drag a table/column from my dataset onto my form, VS2008 automatically populates the form with a binding navigator and some other stuff like the tableadapters and...
1
by: dorkboy | last post by:
Hi all, I am a newbie using VB.net in VS 2008. I took over a vb.net winform application that has a binding navigator in it. The users wanted to add 2 new fields to the form. I added the new...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.