On Jun 19, 9:49 pm, ".\\\\axxx" <mailma...@gmail.com> wrote:
> On Jun 19, 5:29 am, parez <psaw...@gmail.com> wrote:
>
>
>
> > Is there anyway i can find out if a control is an input control
> > (textbox,radiobutton,checkbox,dropdown etc)
> > and not a panel,group box etc.
>
> > I am trying to implement "You have unsaved data on the form.Would you
> > like to save it?" functionality.
> > I created a SaveState method in my base form which adds all textboxes
> > to a dictionary with their values.
> > This method is called when the use saves the form or loads data.
>
> > In the FormClosing event, I check the dictionary for changes in the
> > text boxes and display a modal window if needed.
>
> > This works great.Now I want to extend this functionality for all
> > controls(input controls).
>
> > Should i hardcode all the controls that i am using in my application
> > and check the appropritate propery(.Text, .Checked) or is there any
> > other way?
>
> > TIA
>
> On every project I always subclass all controls - even when I don't
> add any functionalty. That way, if I want to do somehting like this I
> can add a property (via an interface probably), say bool
> IsInputControl or even bool RequiresWarningOnChange. With this, you
> can now iterate your collection of controls, and check the property
> (for those that implement the interface) and only process if it is
> true.
>
> It helps in the long run, because there's _always_ going to be an
> exception that is a textbox you _don't_ want to warn about before
> closing!
That sounds like a great idea(sub classing all controls) and the
interface would have been great.I didnt have to wait too long to see
the need for "RequiresWarningOnChnage". Its too late for me to do
that. I have few days left on this project.
I am storing a llist of controls that dont need to be checked .Thats
how i get away.
|