PC Review


Reply
Thread Tools Rate Thread

check if a control is input control

 
 
parez
Guest
Posts: n/a
 
      18th Jun 2008

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
 
Reply With Quote
 
 
 
 
parez
Guest
Posts: n/a
 
      18th Jun 2008
On Jun 18, 3:29 pm, 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


When i writing the "Should i hardcode all the" line, i realised i
might have to hardcode few types. But i still want the question to
be answered.
Also i can store the hashcodes instead of storing the values.
 
Reply With Quote
 
Pavel Minaev
Guest
Posts: n/a
 
      19th Jun 2008
On Jun 18, 11:29*pm, 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?


There is no general straightforward way to do that, but there are a
few tricks.

If you use data binding for your controls, then you can assume that
any control with bindings that have Binding.DataSourceUpdateMode not
equal to DataSourceUpdateMode.Never is an input control.

Alternatively, you might still want some finer distinction between
input and non-input controls than their class. Tag property may be
used to store a flag, for example, but that would have to be set
manually.
 
Reply With Quote
 
Bjørn Brox
Guest
Posts: n/a
 
      19th Jun 2008
parez skrev:
> 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?
>


Use the "is" statement to test the type in your loop, and remember to
recursively process panels.

--
Bjørn Brox
 
Reply With Quote
 
parez
Guest
Posts: n/a
 
      19th Jun 2008
On Jun 19, 11:42 am, Bjørn Brox <bpb...@gmail.com> wrote:
> parez skrev:
>
>
>
> > 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?

>
> Use the "is" statement to test the type in your loop, and remember to
> recursively process panels.
>
> --
> Bjørn Brox


I have a function that returns a list<somecontrol> that gives me all
somecontrols (recursively) on the form and i loop thru that. And i am
using "is"
Thanks..
 
Reply With Quote
 
.\\\\axxx
Guest
Posts: n/a
 
      20th Jun 2008
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!
 
Reply With Quote
 
parez
Guest
Posts: n/a
 
      20th Jun 2008
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add a control check box to control other checkboxes? JGarland Microsoft Excel Worksheet Functions 1 18th Sep 2008 12:26 PM
Update a date/time control when check box control is updated BrianP Microsoft Access Forms 6 10th Apr 2008 05:04 PM
Input Control =?Utf-8?B?RG1vcnJpMjU0?= Microsoft Excel Worksheet Functions 2 19th Jan 2005 08:21 PM
Showing 1 control inside a 2nd control where the 2nd control is a derived control. malcolm Microsoft Dot NET Framework Forms 0 10th Jun 2004 10:29 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com Microsoft ASP .NET 0 1st Jul 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:28 AM.