473,218 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

check if a control is input control


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
Jun 27 '08 #1
6 1776
On Jun 18, 3:29 pm, parez <psaw...@gmail.comwrote:
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.
Jun 27 '08 #2
On Jun 18, 11:29*pm, parez <psaw...@gmail.comwrote:
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.
Jun 27 '08 #3
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
Jun 27 '08 #4
On Jun 19, 11:42 am, Bjørn Brox <bpb...@gmail.comwrote:
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..
Jun 27 '08 #5
On Jun 19, 5:29*am, parez <psaw...@gmail.comwrote:
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!
Jun 27 '08 #6
On Jun 19, 9:49 pm, ".\\\\axxx" <mailma...@gmail.comwrote:
On Jun 19, 5:29 am, parez <psaw...@gmail.comwrote:
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.
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alain Dhaene | last post by:
Hi I have this problem. I have a function like this. function evaluate(tekst) { var ctrl;
2
by: Nicolae Fieraru | last post by:
Hi All I have a form, with a few input boxes (number of input boxes can vary). Each input box has a name such as in1, in3, in7, etc (their names can be in any order, although increasing). I...
5
by: A.Dagostino | last post by:
hi i need to update an SQL Table when user select or unselect a checkbox control. How Can i do? Thanks Alex
2
by: limbo2u | last post by:
I'm using the following code for a checkbox that when clicked, either checks or unchecks a group of checkboxes on a form. The code works fine, except when there is only one checkbox in the group in...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
5
by: hammer45 | last post by:
Modify payroll program so that it uses a class to store and retrive the employee's name, hourly rate and the number of hours worked. Use a constructor to initialize the employee information, and a...
2
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
3
by: student4lifer | last post by:
I thought the group check boxes would be parsed as an array, but the code below didn't print out as I expected. Could someone explain what I am missing? Thanks. ========== <html> <body>...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.