Hi,
I need to implement a "form.dirty" feature on a VB .NET form not
related to a database. I need to know if any of the items (Textboxes,
combo, listboxes, ...) was changed. Is there a quick and easy way to
do this?
Thanks in advance.
Alain 5 4343
Alain,
I would add a handler for each controls "Changed" event to a single event
Handler that set a Dirty field.
Something like
Public Class MainForm
Private WithEvents TextBox1 As TextBox
Private WithEvents TextBox2 As TextBox
Private WithEvents ComboBox1 As ComboBox
Private WithEvents ListBox1 As ListBox
Private m_dirty As Boolean
Private Sub Form_Changed(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles TextBox1.TextChanged, TextBox2.TextChanged, _
ComboBox1.SelectedValueChanged, ComboBox1.TextChanged _
ListBox1.SelectValueChanged
m_dirty = True
End Sub
Private Sub TextBox1_Changed(ByVal sender As Object, _
ByVal e As EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
Remember that a single event handler can handle multiple events, plus a
single event can be handled by multiple handlers.
An alternative method to the above is to set the Dirty flag in each of the
individual handlers for each control individually.
Hope this helps
Jay
"Alain Filiatrault" <al****@humaprise.com> wrote in message
news:45**************************@posting.google.c om... Hi,
I need to implement a "form.dirty" feature on a VB .NET form not related to a database. I need to know if any of the items (Textboxes, combo, listboxes, ...) was changed. Is there a quick and easy way to do this?
Thanks in advance.
Alain
On Thu, 20 May 2004 08:12:55 -0500, Jay B. Harlow [MVP - Outlook] wrote: Alain, I would add a handler for each controls "Changed" event to a single event Handler that set a Dirty field.
Something like Public Class MainForm
Private WithEvents TextBox1 As TextBox Private WithEvents TextBox2 As TextBox Private WithEvents ComboBox1 As ComboBox Private WithEvents ListBox1 As ListBox
Private m_dirty As Boolean
Private Sub Form_Changed(ByVal sender As Object, _ ByVal e As EventArgs) _ Handles TextBox1.TextChanged, TextBox2.TextChanged, _ ComboBox1.SelectedValueChanged, ComboBox1.TextChanged _ ListBox1.SelectValueChanged m_dirty = True End Sub
Private Sub TextBox1_Changed(ByVal sender As Object, _ ByVal e As EventArgs) Handles TextBox1.TextChanged End Sub
End Class
Remember that a single event handler can handle multiple events, plus a single event can be handled by multiple handlers.
An alternative method to the above is to set the Dirty flag in each of the individual handlers for each control individually.
Hope this helps Jay
Jay, what is the order of the event handlers? Will the TextBox1_Changed
occur first? Or will the Form_Changed occur first? Correct me if I'm
wrong, but if you use AddHandler to wire up the events, the order the
handlers are called will be the order in which they were wired up (FIFO).
Is that correct? But what is the order when using the handles clause?
My follow up question is: If the value in the text box after any text is
typed is the same as the previous value, it may not be necessary to mark
the form as "Dirty". How can you cancel or prevent the Form_Changed
handler from being called? Or is it even possible?
--
Chris
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Chris, what is the order of the event handlers? Will the TextBox1_Changed occur first? Or will the Form_Changed occur first? Correct me if I'm
Does it really matter what the order is? I really don't know what the order
is, nor do I really care.
If the order is important, I would not use WithEvents, I would use
AddHandler itself.
My follow up question is: If the value in the text box after any text is typed is the same as the previous value, it may not be necessary to mark the form as "Dirty". How can you cancel or prevent the Form_Changed handler from being called? Or is it even possible?
Check the definition TextBox.TextChanged event, it is called for each
character typed, if you start with "Help", then type "Help" you will see the
changed event 4 times!
Remember the Changed event suggests that it already occurred, so you cannot
prevent it, you would need to stop the Changing event, however I do not see
that a cancelable TextBox.TextChanging event (you know like the Form.Closing
& Form.Closed events). You could possible do something with the keyboard
events...
Hope this helps
Jay
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:1d*****************************@40tude.net... On Thu, 20 May 2004 08:12:55 -0500, Jay B. Harlow [MVP - Outlook] wrote:
Alain, I would add a handler for each controls "Changed" event to a single
event Handler that set a Dirty field.
Something like Public Class MainForm
Private WithEvents TextBox1 As TextBox Private WithEvents TextBox2 As TextBox Private WithEvents ComboBox1 As ComboBox Private WithEvents ListBox1 As ListBox
Private m_dirty As Boolean
Private Sub Form_Changed(ByVal sender As Object, _ ByVal e As EventArgs) _ Handles TextBox1.TextChanged, TextBox2.TextChanged, _ ComboBox1.SelectedValueChanged, ComboBox1.TextChanged _ ListBox1.SelectValueChanged m_dirty = True End Sub
Private Sub TextBox1_Changed(ByVal sender As Object, _ ByVal e As EventArgs) Handles TextBox1.TextChanged End Sub
End Class
Remember that a single event handler can handle multiple events, plus a single event can be handled by multiple handlers.
An alternative method to the above is to set the Dirty flag in each of
the individual handlers for each control individually.
Hope this helps Jay
Jay, what is the order of the event handlers? Will the TextBox1_Changed occur first? Or will the Form_Changed occur first? Correct me if I'm wrong, but if you use AddHandler to wire up the events, the order the handlers are called will be the order in which they were wired up (FIFO). Is that correct? But what is the order when using the handles clause?
My follow up question is: If the value in the text box after any text is typed is the same as the previous value, it may not be necessary to mark the form as "Dirty". How can you cancel or prevent the Form_Changed handler from being called? Or is it even possible?
-- Chris
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and replace certain words in my E-Mail address.
Chris, what is the order of the event handlers? Will the TextBox1_Changed occur first? Or will the Form_Changed occur first? Correct me if I'm
Does it really matter what the order is? I really don't know what the order
is, nor do I really care.
If the order is important, I would not use WithEvents, I would use
AddHandler itself.
My follow up question is: If the value in the text box after any text is typed is the same as the previous value, it may not be necessary to mark the form as "Dirty". How can you cancel or prevent the Form_Changed handler from being called? Or is it even possible?
Check the definition TextBox.TextChanged event, it is called for each
character typed, if you start with "Help", then type "Help" you will see the
changed event 4 times!
Remember the Changed event suggests that it already occurred, so you cannot
prevent it, you would need to stop the Changing event, however I do not see
that a cancelable TextBox.TextChanging event (you know like the Form.Closing
& Form.Closed events). You could possible do something with the keyboard
events...
Hope this helps
Jay
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:1d*****************************@40tude.net... On Thu, 20 May 2004 08:12:55 -0500, Jay B. Harlow [MVP - Outlook] wrote:
Alain, I would add a handler for each controls "Changed" event to a single
event Handler that set a Dirty field.
Something like Public Class MainForm
Private WithEvents TextBox1 As TextBox Private WithEvents TextBox2 As TextBox Private WithEvents ComboBox1 As ComboBox Private WithEvents ListBox1 As ListBox
Private m_dirty As Boolean
Private Sub Form_Changed(ByVal sender As Object, _ ByVal e As EventArgs) _ Handles TextBox1.TextChanged, TextBox2.TextChanged, _ ComboBox1.SelectedValueChanged, ComboBox1.TextChanged _ ListBox1.SelectValueChanged m_dirty = True End Sub
Private Sub TextBox1_Changed(ByVal sender As Object, _ ByVal e As EventArgs) Handles TextBox1.TextChanged End Sub
End Class
Remember that a single event handler can handle multiple events, plus a single event can be handled by multiple handlers.
An alternative method to the above is to set the Dirty flag in each of
the individual handlers for each control individually.
Hope this helps Jay
Jay, what is the order of the event handlers? Will the TextBox1_Changed occur first? Or will the Form_Changed occur first? Correct me if I'm wrong, but if you use AddHandler to wire up the events, the order the handlers are called will be the order in which they were wired up (FIFO). Is that correct? But what is the order when using the handles clause?
My follow up question is: If the value in the text box after any text is typed is the same as the previous value, it may not be necessary to mark the form as "Dirty". How can you cancel or prevent the Form_Changed handler from being called? Or is it even possible?
-- Chris
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and replace certain words in my E-Mail address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Davis |
last post by:
I want to know what's the differences between
Request.Form("Field Name") and
Request.QueryString("Field Name")
OR they function exactly the same, which is to return the value of the
field??
...
|
by: Hodad |
last post by:
I would like to adapt, as much as possible, the appearance and color red
of the
font in this button:
<P><CENTER><BUTTON VALUE="SUBMIT"><A...
|
by: Pavils Jurjans |
last post by:
Hello,
I have bumped upon this problem: I do some client-side form processing
with JavaScript, and for this I loop over all the forms in the
document. In order to identify them, I read their...
|
by: nutthatch |
last post by:
I want to be able to import an Excel spreadsheet into Access 2K using
the macro command Transferspreadsheet.
However, the file I am importing (over which I have no control)
contains some records...
|
by: Dan |
last post by:
I am trying to use
Request.Form("__EVENTTARGET") to get the name of the control that caused a post back. It keeps returning "".
I am not really sure why, this happens for all of my controls...
| |
by: Mitchell Vincent |
last post by:
I've been trying to get a standard toolbar to play nice with some nice icons
that I have. When I put them on a button or anything they look perfect, but
through an imagelist and on a toolbar they...
|
by: Rich |
last post by:
Hi,
I was experimenting with some basic sample asp code but can't get it to work
correctly:
this is bgselector.asp which works OK - you add the name of a basic color
like blue, green, yellow...
|
by: Sanders Kaufman |
last post by:
I'm converting my table-based layouts to css-positioned divs - but the
ONLY reason I'm doing it is because it's *considered* a best practice.
I don't really see where anything goes hinky when...
|
by: eBob.com |
last post by:
How does a "sub-form", i.e. one invoked by another form, determine anything
about the form which brought it into existence, i.e., I suppose,
instantiated it? I wanted to so something like this ......
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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...
| |