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 4358
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(By Val sender As Object, _
ByVal e As EventArgs) _
Handles TextBox1.TextCh anged, TextBox2.TextCh anged, _
ComboBox1.Selec tedValueChanged , ComboBox1.TextC hanged _
ListBox1.Select ValueChanged
m_dirty = True
End Sub
Private Sub TextBox1_Change d(ByVal sender As Object, _
ByVal e As EventArgs) Handles TextBox1.TextCh anged
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****@humapri se.com> wrote in message
news:45******** *************** ***@posting.goo gle.com... 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(By Val sender As Object, _ ByVal e As EventArgs) _ Handles TextBox1.TextCh anged, TextBox2.TextCh anged, _ ComboBox1.Selec tedValueChanged , ComboBox1.TextC hanged _ ListBox1.Select ValueChanged m_dirty = True End Sub
Private Sub TextBox1_Change d(ByVal sender As Object, _ ByVal e As EventArgs) Handles TextBox1.TextCh anged 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_Change d
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_Change d 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.TextCha nged 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.TextCha nging 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_sbcg lobal[dot]]net"> wrote in
message news:1d******** *************** ******@40tude.n et... 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(By Val sender As Object, _ ByVal e As EventArgs) _ Handles TextBox1.TextCh anged, TextBox2.TextCh anged, _ ComboBox1.Selec tedValueChanged , ComboBox1.TextC hanged _ ListBox1.Select ValueChanged m_dirty = True End Sub
Private Sub TextBox1_Change d(ByVal sender As Object, _ ByVal e As EventArgs) Handles TextBox1.TextCh anged 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_Change d 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_Change d 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.TextCha nged 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.TextCha nging 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_sbcg lobal[dot]]net"> wrote in
message news:1d******** *************** ******@40tude.n et... 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(By Val sender As Object, _ ByVal e As EventArgs) _ Handles TextBox1.TextCh anged, TextBox2.TextCh anged, _ ComboBox1.Selec tedValueChanged , ComboBox1.TextC hanged _ ListBox1.Select ValueChanged m_dirty = True End Sub
Private Sub TextBox1_Change d(ByVal sender As Object, _ ByVal e As EventArgs) Handles TextBox1.TextCh anged 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_Change d 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??
Thanks,
John
|
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
HREF="http://www.familytreedna.com/surname_join.asp?code=Q17978"
STYLE="TEXT-DECORATION: NONE;">
<FONT COLOR="RED" FACE="COPPERPLATE GOTHIC BOLD">Right
Here</FONT></A></BUTTON></CENTER></P>
|
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 "name" property
(which sources from "name" HTML attribue). The problem is, that if the
form contains form control named "name", it overwrites the form name
property. In fact, I'm quite surprised that it's so easy to spoil any
of the form object...
|
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 that are "dirty" i.e. the field contents do not
comply with the expected format (date/time) and they end up in a
seperate table of import errors. (The records in "error" are actually
empty fields.)
This is a regular event and I do not want to...
|
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 that invoke are invoking a post back.
I've never used this type of method before, but I need to get the name of the control doing the postback in the Form Load event, and cannot wait until the event of the target control that runs due to the...
| |
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 all have this blue aura around
them. I assume that is from the transparency, but I don't understand why
almost any other control displays them properly.. There really is no
replacement for the toolbar (without paying!), so I hope someone can tell...
|
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 and call another asp called backcolor.asp where I
have the problem:
bgselector.asp
|
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 tables are used - but
I'm doing it anyway because the HTML and CSS specs says to reserve
tables for tabular data.
So as I convert my login widgit to a css thing, I'm saying to myself -
hey, this form is most certainly "tabular data" - even if it...
|
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 ...
MsgBox("called by " & Owner.Name)
.... but that throws a null reference exception. Parent.Name and
ParentForm.Name also throw null reference exceptions. Form1.Name works -
but that's not very flexible.
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |