473,408 Members | 2,477 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,408 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 1785
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...
0
isladogs
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...

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.