473,618 Members | 3,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.btnDe lete.enabled = navigator.bindi ngSource.AllowR emove

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

So I tried to do the same from a dataview.

Dim dv as DataView = New DataView(myTabl e)
navigator.btnDe lete.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 2787
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.Del eteCommand is Nothing

Hope this helps...

Daniel.

"Rick" <Ri**@LakeValle ySeed.comwrote in message
news:eR******** ******@TK2MSFTN GP05.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.btnDe lete.enabled = navigator.bindi ngSource.AllowR emove

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

So I tried to do the same from a dataview.

Dim dv as DataView = New DataView(myTabl e)
navigator.btnDe lete.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***@buhlelec tric.comwrote in message
news:uF******** ******@TK2MSFTN GP03.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.Del eteCommand is Nothing

Hope this helps...

Daniel.

"Rick" <Ri**@LakeValle ySeed.comwrote in message
news:eR******** ******@TK2MSFTN GP05.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.btnD elete.enabled = navigator.bindi ngSource.AllowR emove

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

So I tried to do the same from a dataview.

Dim dv as DataView = New DataView(myTabl e)
navigator.btnD elete.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***@buhlelec tric.comwrote in message
news:uF******** ******@TK2MSFTN GP03.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.Del eteCommand is Nothing

Hope this helps...

Daniel.

"Rick" <Ri**@LakeValle ySeed.comwrote in message
news:eR******** ******@TK2MSFTN GP05.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.btnD elete.enabled = navigator.bindi ngSource.AllowR emove

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

So I tried to do the same from a dataview.

Dim dv as DataView = New DataView(myTabl e)
navigator.btnD elete.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
4219
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); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
0
957
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 that! <g>). The issue I have is that after I open the form, the first record is displayed. I click the "move to next item" arrow and move to record 2. Repeat that, move to record 3. Next click moves to record 2. From there, I toggle between records 2...
1
2920
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 access information of tables on Windows Form. It is working properly. i can see all the records properly.
0
1467
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 ideas? This project previously used a SQL database and it worked fine. I deleted that datasource, added new access datasource and now I have this issue. Weird.
2
3293
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, my question can be asked from two directions: 1. Is the binding navigator code visible somewhere? If it is, I'll just copy it from there into my procedure. 2. What is the code that the binding navigator uses to add this blank row without...
2
10077
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 record. Here is what I have so far: Dim strSQL As String strSQL = "SELECT OrderID WHERE OrderID = @OrderID" Dim cmdSelect As New SqlCommand(strSQL, cn) cmdSelect.Parameters.AddWithValue("@OrderID, cboOrderID.text)
1
1733
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 here is the code snippet: I have a datagridview and a detailView in form load:
1
2743
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 bindingsources. I was just wondering about the codes that the bindingnavigator uses to add or move to next or first or last etc... i tried viewing the code of the binding navigator itself, but the only code that is written is the code that commits...
1
2392
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 fields to the SQL Server 2005 database. I refreshed the Data Source tab in the project. It recognizes the 2 new fields. I dragged them onto the form.
0
8212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8595
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7126
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6101
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.