Application Architecture Question 
Author Message
 Application Architecture Question

Sorry to repost this, but I'm really interested in getting ideas.

I'm building a technical app with many textboxes for data entry. What's
the best way to mark the "Dirty" property of clsFile as True and
enable the File|Save menu whenever a user changes text in any textbox?
If user exits a text box without making changes, the state of the Dirty
property and File/Save should not change.

clsLink.CustName is a public property that stores the customer name.

I started using following code in the textbox tbProjDescrip LostFocus
handler:

Private Sub tbProjDescrip_LostFocus(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles tbProjDescrip.LostFocus

    If Not Link.CustName Is Nothing Then    ' Check to avoid compiler
complaint about object not instantiated

        If tbProjDescrip.Text.ToString <> Link.ProjDescript.ToString Then
' Check to see if text in box changed. If it has, mark file "Dirty" for
saving & turn on menu

            TheFile.Dirty = True                            ' Mark file
"Dirty"

            mnuFileSave.Enabled = True                ' Turn on "Save" menu.
Move this to clsFile.Dirty property

           Link.ProjDescript = tbProjDescrip.Text    ' Store new value in
object property

        End If

    End If

End Sub

With this approach, I never get past the "If Not Link.CustName Is Nothing
Then" because the textbox starts off empty.

What's the best way to handle this common program problem with minimal code?

Thanks in advance for any help!

Steve



Sat, 29 Jan 2005 05:51:49 GMT  
 Application Architecture Question
try handling the "TextBox.TextChanged" event instead of LostFocus

also in your code, why are you checking "If Not Link.CustName Is Nothing
Then" when you are not using CustName in the code inside the condition ? is
it a requirement of the logic in your program ?

thanks,
VB Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Sorry to repost this, but I'm really interested in getting ideas.

> I'm building a technical app with many textboxes for data entry. What's
> the best way to mark the "Dirty" property of clsFile as True and
> enable the File|Save menu whenever a user changes text in any textbox?
> If user exits a text box without making changes, the state of the Dirty
> property and File/Save should not change.

> clsLink.CustName is a public property that stores the customer name.

> I started using following code in the textbox tbProjDescrip LostFocus
> handler:

> Private Sub tbProjDescrip_LostFocus(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles tbProjDescrip.LostFocus

>     If Not Link.CustName Is Nothing Then    ' Check to avoid compiler
> complaint about object not instantiated

>         If tbProjDescrip.Text.ToString <> Link.ProjDescript.ToString Then
> ' Check to see if text in box changed. If it has, mark file "Dirty" for
> saving & turn on menu

>             TheFile.Dirty = True                            ' Mark file
> "Dirty"

>             mnuFileSave.Enabled = True                ' Turn on "Save"
menu.
> Move this to clsFile.Dirty property

>            Link.ProjDescript = tbProjDescrip.Text    ' Store new value in
> object property

>         End If

>     End If

> End Sub

> With this approach, I never get past the "If Not Link.CustName Is Nothing
> Then" because the textbox starts off empty.

> What's the best way to handle this common program problem with minimal
code?

> Thanks in advance for any help!

> Steve



Sun, 30 Jan 2005 03:31:31 GMT  
 Application Architecture Question
I didn't want to use TextChanged because I am triggering a scientific calc
that involves getting SQL data, loading a couple of ListViews, lots of
technical calcs, redrawing results in MSChart, etc. The calc is pretty fast,
but I want to trigger it when the user leaves a textbox, not every time a
new number is typed.

I'm checking the class property to see if it exists. If it does exist, then
compare it to new value in the textbox. If there's no change, don't change
state of boolean "Dirty." If user has changed textbox value from previous
state (stored in class prop), then set boolean "Dirty" to true to indicate I
need to save file and enable File|Save.

What I was really hoping to learn was a major architectural approach to
tracking changes to textboxes and flagging the file as Dirty. I haven't seen
this addressed in any of my books or sample programs from various web
sources.

Thanks,
Steve



Quote:
> try handling the "TextBox.TextChanged" event instead of LostFocus

> also in your code, why are you checking "If Not Link.CustName Is Nothing
> Then" when you are not using CustName in the code inside the condition ?
is
> it a requirement of the logic in your program ?

> thanks,
> VB Team

> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.



> > Sorry to repost this, but I'm really interested in getting ideas.

> > I'm building a technical app with many textboxes for data entry. What's
> > the best way to mark the "Dirty" property of clsFile as True and
> > enable the File|Save menu whenever a user changes text in any textbox?
> > If user exits a text box without making changes, the state of the Dirty
> > property and File/Save should not change.

> > clsLink.CustName is a public property that stores the customer name.

> > I started using following code in the textbox tbProjDescrip LostFocus
> > handler:

> > Private Sub tbProjDescrip_LostFocus(ByVal sender As System.Object, ByVal
e
> > As System.EventArgs) Handles tbProjDescrip.LostFocus

> >     If Not Link.CustName Is Nothing Then    ' Check to avoid compiler
> > complaint about object not instantiated

> >         If tbProjDescrip.Text.ToString <> Link.ProjDescript.ToString
Then
> > ' Check to see if text in box changed. If it has, mark file "Dirty" for
> > saving & turn on menu

> >             TheFile.Dirty = True                            ' Mark file
> > "Dirty"

> >             mnuFileSave.Enabled = True                ' Turn on "Save"
> menu.
> > Move this to clsFile.Dirty property

> >            Link.ProjDescript = tbProjDescrip.Text    ' Store new value
in
> > object property

> >         End If

> >     End If

> > End Sub

> > With this approach, I never get past the "If Not Link.CustName Is
Nothing
> > Then" because the textbox starts off empty.

> > What's the best way to handle this common program problem with minimal
> code?

> > Thanks in advance for any help!

> > Steve



Sun, 30 Jan 2005 05:36:14 GMT  
 Application Architecture Question
You seem to want to do the same thing that HTML's <INPUT Type=Text
onChange='...'> will do.  Yes?  If so, then you seem to be doing the right
thing. The only other suggestion we might make is to set the TextBox's
CausesValidation Property to true and then handle the TextBox's "Validating"
event in place of LostFocus

In case you are not interested in AutoSave, then you could probably check
for Changes only when somebody clicks on your File Menu to decide whether to
enable or disable the Save

thanks,
VB Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> I didn't want to use TextChanged because I am triggering a scientific calc
> that involves getting SQL data, loading a couple of ListViews, lots of
> technical calcs, redrawing results in MSChart, etc. The calc is pretty
fast,
> but I want to trigger it when the user leaves a textbox, not every time a
> new number is typed.

> I'm checking the class property to see if it exists. If it does exist,
then
> compare it to new value in the textbox. If there's no change, don't change
> state of boolean "Dirty." If user has changed textbox value from previous
> state (stored in class prop), then set boolean "Dirty" to true to indicate
I
> need to save file and enable File|Save.

> What I was really hoping to learn was a major architectural approach to
> tracking changes to textboxes and flagging the file as Dirty. I haven't
seen
> this addressed in any of my books or sample programs from various web
> sources.

> Thanks,
> Steve



> > try handling the "TextBox.TextChanged" event instead of LostFocus

> > also in your code, why are you checking "If Not Link.CustName Is Nothing
> > Then" when you are not using CustName in the code inside the condition ?
> is
> > it a requirement of the logic in your program ?

> > thanks,
> > VB Team

> > --
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.



> > > Sorry to repost this, but I'm really interested in getting ideas.

> > > I'm building a technical app with many textboxes for data entry.
What's
> > > the best way to mark the "Dirty" property of clsFile as True and
> > > enable the File|Save menu whenever a user changes text in any textbox?
> > > If user exits a text box without making changes, the state of the
Dirty
> > > property and File/Save should not change.

> > > clsLink.CustName is a public property that stores the customer name.

> > > I started using following code in the textbox tbProjDescrip LostFocus
> > > handler:

> > > Private Sub tbProjDescrip_LostFocus(ByVal sender As System.Object,
ByVal
> e
> > > As System.EventArgs) Handles tbProjDescrip.LostFocus

> > >     If Not Link.CustName Is Nothing Then    ' Check to avoid compiler
> > > complaint about object not instantiated

> > >         If tbProjDescrip.Text.ToString <> Link.ProjDescript.ToString
> Then
> > > ' Check to see if text in box changed. If it has, mark file "Dirty"
for
> > > saving & turn on menu

> > >             TheFile.Dirty = True                            ' Mark
file
> > > "Dirty"

> > >             mnuFileSave.Enabled = True                ' Turn on "Save"
> > menu.
> > > Move this to clsFile.Dirty property

> > >            Link.ProjDescript = tbProjDescrip.Text    ' Store new value
> in
> > > object property

> > >         End If

> > >     End If

> > > End Sub

> > > With this approach, I never get past the "If Not Link.CustName Is
> Nothing
> > > Then" because the textbox starts off empty.

> > > What's the best way to handle this common program problem with minimal
> > code?

> > > Thanks in advance for any help!

> > > Steve



Mon, 31 Jan 2005 03:30:41 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Application Architecture Question

2. VB Applications Architecture Questions

3. VB Applications Architecture Questions

4. Application architecture ...

5. sample application using windows form in a distributed architecture model

6. RFC:.NET Application Architecture

7. Application code, design and architecture review material???

8. Developing a plugin architecture for a VB5/6 application

9. Application architecture

10. REQ: Application architecture advise

11. Application code, design and architecture review material???

12. Application code, design and architecture review material???

 

 
Powered by phpBB® Forum Software