473,545 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catch changes made by user

I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and all controls are populated with data from
the selected row.
The grid is going to be read only. Textboxes, checkboxes are going to be
read/write.
What event and how do I need to use to catch any change in any of the
textboxes? I tried to use TextBox_TextCha nged, but it fires during initial
population and every time I change the active row in the grid. How can I
distinguish between changes made by the program and changes made by the
user?
I need to set the flag blnIsThereAnyCh ange = True when user changes the
contents of the textbox, and use the value of that flag in some procedures.

Thank you
vovan

Oct 5 '07 #1
5 5166
vovan,

Since you are using bound controls, any changes in the textboxes will be
reflected in the underlying datatable.

So you could use datatable.HasCh anges to see if any changes have been made.

Kerry Moorman
"vovan" wrote:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and all controls are populated with data from
the selected row.
The grid is going to be read only. Textboxes, checkboxes are going to be
read/write.
What event and how do I need to use to catch any change in any of the
textboxes? I tried to use TextBox_TextCha nged, but it fires during initial
population and every time I change the active row in the grid. How can I
distinguish between changes made by the program and changes made by the
user?
I need to set the flag blnIsThereAnyCh ange = True when user changes the
contents of the textbox, and use the value of that flag in some procedures.

Thank you
vovan

Oct 5 '07 #2
Use the Enter and Leave events of the TextBoxes and CheckBoxes to Add and
Remove the Change handlers for those controls.

Here is an example for a checkbox--

Private Sub CheckBox1_Check edEnter(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles CheckBox1.Enter
AddHandler CheckBox1.Check StateChanged, _
AddressOf CheckBox1_Check edChanged
End Sub

Private Sub CheckBox1_Leave (ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles CheckBox1.Leave
RemoveHandler CheckBox1.Check StateChanged, _
AddressOf CheckBox1_Check edChanged
End Sub

Private Sub CheckBox1_Check edChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s)
'add code here
End Sub

When the user changes the check of a checkbox, the enter event will fire
first and add the checkchange event hander. Then the checkstatechang ed event
will fire and read the new value for the checkbox.

If you have a lot of textbox and checkbox controls, you could, (from within
the form_load event), consolidate your code by pointing all of the Enter
addhandler statements for one control type to a single code block, and
likewise for Leave. If you do that, of course, the "sender" object is the
control that fired Enter or Leave, and you should use cast the objectly
appropriately.. .
directcast(send er, Textbox)

When you want to detect whether a change has been made for any control, you
have to come up with a monitoring system that captures original values after
the controls are populated. If the user makes changes, comare the current
value to the original value, and set the flag for the control accordingly.
If the user re-sets to the original value, your change flag should be reset
to false for that entry. This also gives you an opportunity to have a Cancel
Changes button that restores all changes to the current record to their
current unchanged values. You may be able to use the grid row as your
original values reference, but sometimes, by design, a grid will not show all
values that are shown in the controls on the form.
"vovan" wrote:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and all controls are populated with data from
the selected row.
The grid is going to be read only. Textboxes, checkboxes are going to be
read/write.
What event and how do I need to use to catch any change in any of the
textboxes? I tried to use TextBox_TextCha nged, but it fires during initial
population and every time I change the active row in the grid. How can I
distinguish between changes made by the program and changes made by the
user?
I need to set the flag blnIsThereAnyCh ange = True when user changes the
contents of the textbox, and use the value of that flag in some procedures.

Thank you
vovan

Oct 5 '07 #3
Thank you Kerry
HasChanges is a method of Dataset object. When I make any change in the
bound controls and do not move to another record, probably changes are not
moved yet from controls to the Dataset and when I'm calling HasChanges it
returns FALSE.
First of all it seem inconvenient for me to move to another row to check if
there were changes. The second issue is how do I check if changes occured, I
mean what event of what object I need to use to find it out.
My plans were:
I'm staying on the particular row in the grid, if I make any change in any
bound control, I set somehow the flag responsible for changes to true, at
the same time I change the visible properties of buttons "AddNew", "Update",
"Cancel", Delete". If user is trying to move to another row I display a
message box asking if she wants to save changes. Changes are saved for each
row separately.
I was going to use TextChanged event for textboxes to reset the flag, but as
I said before it fires not only from user actions.

vovan

"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:C3******** *************** ***********@mic rosoft.com...
vovan,

Since you are using bound controls, any changes in the textboxes will be
reflected in the underlying datatable.

So you could use datatable.HasCh anges to see if any changes have been
made.

Kerry Moorman
"vovan" wrote:
>I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and all controls are populated with data
from
the selected row.
The grid is going to be read only. Textboxes, checkboxes are going to be
read/write.
What event and how do I need to use to catch any change in any of the
textboxes? I tried to use TextBox_TextCha nged, but it fires during
initial
population and every time I change the active row in the grid. How can I
distinguish between changes made by the program and changes made by the
user?
I need to set the flag blnIsThereAnyCh ange = True when user changes the
contents of the textbox, and use the value of that flag in some
procedures.

Thank you
vovan


Oct 5 '07 #4
vovan,

Perhaps you could use the datatable's RowChanging, RowChanged,
ColumnChanging or ColumnChanged events.

Personally, I would avoid trying to use textbox events to determine if the
data is changing. I have rarely seen that work out well.

Kerry Moorman
"vovan" wrote:
Thank you Kerry
HasChanges is a method of Dataset object. When I make any change in the
bound controls and do not move to another record, probably changes are not
moved yet from controls to the Dataset and when I'm calling HasChanges it
returns FALSE.
First of all it seem inconvenient for me to move to another row to check if
there were changes. The second issue is how do I check if changes occured, I
mean what event of what object I need to use to find it out.
My plans were:
I'm staying on the particular row in the grid, if I make any change in any
bound control, I set somehow the flag responsible for changes to true, at
the same time I change the visible properties of buttons "AddNew", "Update",
"Cancel", Delete". If user is trying to move to another row I display a
message box asking if she wants to save changes. Changes are saved for each
row separately.
I was going to use TextChanged event for textboxes to reset the flag, but as
I said before it fires not only from user actions.

vovan

"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:C3******** *************** ***********@mic rosoft.com...
vovan,

Since you are using bound controls, any changes in the textboxes will be
reflected in the underlying datatable.

So you could use datatable.HasCh anges to see if any changes have been
made.

Kerry Moorman
"vovan" wrote:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and all controls are populated with data
from
the selected row.
The grid is going to be read only. Textboxes, checkboxes are going to be
read/write.
What event and how do I need to use to catch any change in any of the
textboxes? I tried to use TextBox_TextCha nged, but it fires during
initial
population and every time I change the active row in the grid. How can I
distinguish between changes made by the program and changes made by the
user?
I need to set the flag blnIsThereAnyCh ange = True when user changes the
contents of the textbox, and use the value of that flag in some
procedures.

Thank you
vovan



Oct 5 '07 #5
I agree that detecting changes with text box events rarely works out as the
programmer intends. What I would suggest is that you have a class containing
all the record data then when the row changes, check in the row changed event
if the text boxes contain the same info...if not, update the previous record
then reset the class properties to the new row data.

Hope you can get some ideas from this.
--
Dennis in Houston
"vovan" wrote:
Thank you Kerry
HasChanges is a method of Dataset object. When I make any change in the
bound controls and do not move to another record, probably changes are not
moved yet from controls to the Dataset and when I'm calling HasChanges it
returns FALSE.
First of all it seem inconvenient for me to move to another row to check if
there were changes. The second issue is how do I check if changes occured, I
mean what event of what object I need to use to find it out.
My plans were:
I'm staying on the particular row in the grid, if I make any change in any
bound control, I set somehow the flag responsible for changes to true, at
the same time I change the visible properties of buttons "AddNew", "Update",
"Cancel", Delete". If user is trying to move to another row I display a
message box asking if she wants to save changes. Changes are saved for each
row separately.
I was going to use TextChanged event for textboxes to reset the flag, but as
I said before it fires not only from user actions.

vovan

"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:C3******** *************** ***********@mic rosoft.com...
vovan,

Since you are using bound controls, any changes in the textboxes will be
reflected in the underlying datatable.

So you could use datatable.HasCh anges to see if any changes have been
made.

Kerry Moorman
"vovan" wrote:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and all controls are populated with data
from
the selected row.
The grid is going to be read only. Textboxes, checkboxes are going to be
read/write.
What event and how do I need to use to catch any change in any of the
textboxes? I tried to use TextBox_TextCha nged, but it fires during
initial
population and every time I change the active row in the grid. How can I
distinguish between changes made by the program and changes made by the
user?
I need to set the flag blnIsThereAnyCh ange = True when user changes the
contents of the textbox, and use the value of that flag in some
procedures.

Thank you
vovan



Oct 6 '07 #6

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

Similar topics

2
4372
by: Galina | last post by:
Hello I have an application in MS Access 2000. I have a form, which includes a subform. The subform is based on a table, but locked for any editing. There is Edit button. When clicked, it starts a separate unbound form with all the fields, which are on the subform. The fields are filled in with data programmatically. User edits. Edited fields...
12
2657
by: Andrew Schepler | last post by:
When compiled with Visual C++ .NET 2003 (only), the program below aborts as though no matching catch clause is present. If the copy constructor of A is made public, it successfully catches the exception instead. If I step into __CxxThrowException in debug/assembly mode, it looks like the pThrowInfo parameter created by the compiler excluded...
23
3042
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally block. But, I prefer to dim them "on the fly" only if needed (save as much resources as possible). A little further... I may wish to create a sqlcommand...
2
4426
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist then skip this file and move onto the next file (line). If file is there then move to a sirectory. Here is the code I have (Feel free to make...
2
1659
by: Brian Hoops | last post by:
I have a windows forms datagrid and I would like to be able to recognize when changes have been made in order to perform the update. I tried the following, which works well, but only if the user changes rows at some point. If they enter the grid, change a cell, and then click close it does not see the change. The same holds true if they...
30
3356
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on...
3
4904
by: =?Utf-8?B?QnJhbmRvbg==?= | last post by:
Hi, I have an aspx page that has the "include" code in it which includes another page that displays information. I also have an upload page that allows users to upload a simple html document onto the server. The include code calls that html page to display the text on that page. The problem is when the user uploads that html page, the aspx...
11
4122
by: gyap88 | last post by:
Hello i m using vb 2005 express to do my project. I m suppose to create a datagrid to allow user to make changes to the database. The program display the database in a datagrid where users can juz make changes there. I encountered a problem when user are trying save changes. The following code is executed when the save button is click: ...
3
4170
by: dirksza2009 | last post by:
Hi, I've made a multi user (4 end users) database in Access 2000. I've made data tables, reference tables etc which sits on a shared drive and I've made individual front ends for the end users which gives them specific views of the data. I'd like to track all the changes made to a record which works find with the following code : ...
0
7475
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...
0
7409
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...
0
7664
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. ...
1
7436
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...
0
5981
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...
1
5341
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...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1897
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
715
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...

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.