473,671 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bound Controls Update Events

Hi

I'm using bound controls on a windows form such as textboxes, checkboxes
etc. which work fine except for one thing...

If you click on a checkbox for example its value changes visibly and also
the value changes in the underlying data table - but no events are fired
until you move to a new column or row.

Does anyone know of a way of being notified when the fields value starts
being changed - a begin_edit type of event ?

I know I could put code into every controls change events etc but I was
hoping there was an event which I am missing ?
Nov 21 '05 #1
4 1426
Lenster,

The value is put in the underlying datasource, when the events from the
control are evaluated.

So why not use those control events for this purpose, they are made for it.

This sentence bellow of you is in my opinion not true
If you click on a checkbox for example its value changes visibly and also
the value changes in the underlying data table


I made a sample for you to show you that, it is bellow you have to drag on a
newprojectform a checkbox and a button and than paste in this code.

I hope this helps?

Cor

\\\
Public mcheckitem As Boolean
Public Property checkitem() As Boolean
Get
Return mcheckitem
End Get
Set(ByVal Value As Boolean)
mcheckitem = Value
End Set
End Property

Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.CheckBox1.Da taBindings.Add( "Checked", Me, "checkitem" )
End Sub

Private Sub CheckBox1_Click (ByVal sender As Object, _
ByVal e As System.EventArg s) Handles CheckBox1.Click
MessageBox.Show (mcheckitem.ToS tring)
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
MessageBox.Show (mcheckitem.ToS tring)
End Sub
///
Nov 21 '05 #2
Thanks Cor

You are absouletly right about the value in the underlying datasource not
changing until you move off the control I was mistaken.

I take your point about using each controls events to determine when changes
to the fields are happening but I was hoping to avoid this.
If I have to add code to the click/change events of each control it defeats
the object of binding the controls to a datasource in my opinion. I may
aswell use these click/change events to manually update my underlying
datastructures.

Currently when I get a datatable.colum nchanged event (when focus moves from
a bound textbox etc) I perform validation and fire an event of my own which
the form handles and then enables/disabled the save button etc. This means
that if a value is changed but focus doesn't move from the control the save
button never gets enabled.

Not to worry I will have a rethink - Thanks for your help :¬)


"Cor Ligthert" wrote:
Lenster,

The value is put in the underlying datasource, when the events from the
control are evaluated.

So why not use those control events for this purpose, they are made for it.

This sentence bellow of you is in my opinion not true
If you click on a checkbox for example its value changes visibly and also
the value changes in the underlying data table


I made a sample for you to show you that, it is bellow you have to drag on a
newprojectform a checkbox and a button and than paste in this code.

I hope this helps?

Cor

\\\
Public mcheckitem As Boolean
Public Property checkitem() As Boolean
Get
Return mcheckitem
End Get
Set(ByVal Value As Boolean)
mcheckitem = Value
End Set
End Property

Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.CheckBox1.Da taBindings.Add( "Checked", Me, "checkitem" )
End Sub

Private Sub CheckBox1_Click (ByVal sender As Object, _
ByVal e As System.EventArg s) Handles CheckBox1.Click
MessageBox.Show (mcheckitem.ToS tring)
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
MessageBox.Show (mcheckitem.ToS tring)
End Sub
///

Nov 21 '05 #3
Lenster,

Did you know that it is easy possible to make by instance one Click event
for all your controls?

Cor
Nov 21 '05 #4
Lester

I think on the validating event, and than more like this below, all typed
(partialy first pasted) here and not tested.

I hope this helps?

Cor

\\\
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Contr ols
if typeof ctr Is Textbox then
AddHandler ctr.Validate, AddressOf meValidating
end if
doSet(ctr)
Next
End Sub
Private Sub meValidating(By Val sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs)
Select case directcast(send er,textbox).nam e
Case "txtName"
'blabla
Case "txtStreet"
'blabla
Case Else
'blabla
End select
End Sub
///

Cor

Nov 21 '05 #5

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

Similar topics

3
2431
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from code it is 50% chance that the update will make it back to the dataset. If I update the dataset instead of the form, it does not show on the form. Is there a method that should be used?
19
4093
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
14
10128
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought I should give back to the community by posting our findings. Thanks you all for all your help till now by posting problems and their solutions. ~Abhijit
4
2722
by: gj | last post by:
Hi, I'm trying to update a sql database from a web form using text boxes. I'm trying to learn C# on my own so I am at a complete loss. I created my sql connection, data adapter, dataset and data view in the visual studio designer. I'm trying to keep a history of the record so instead of editing the record I insert a new record with my changes. Instead of the changes, it inserts the orginal record. Below is the part of the code. Any help...
3
6123
by: Samuel R. Neff | last post by:
We're working on implementing a Command Pattern design with our application in order to help facilitate undo/redo. This is fine four user actions we control which basically means menu actions. However, it's not quite so clear for bound controls. We don't directly interact with the change--the user makes a change in a control, such as a grid, and the dataset stores the update. We haven't interjected any code which we can funnel through...
2
2705
by: Aaron Ackerman | last post by:
I cannot a row to this bound DataGrid to SAVE MY LIFE! I have tried everything and I am at a loss. The using goes into add mode with the add button adds his data then updates with the update button, seems simple. I am using ALL visual controls (supposedly to simplify things. If I was not using the visual controls and calling an ExecuteNonQuery no prob. Please look at my code and tell me what I am doing wrong. Also, what are the advatages...
4
4613
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
0
2007
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number of different screens down to a minimum, I'm trying to use the same Windows Forms for both browsing and for updating. This works fine for TextBoxes, but I'm running into problems with my DropDownLists (ComboBoxes).
0
2490
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. In this table there are multiple columns that cannot be NULL, which, are bound to other controls (but they're not really important at this time). I create a new row via the currency manager like so: _currencyManager.AddNew() _currentRow =...
0
8392
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8912
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...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
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
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1807
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.