473,614 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enable / Disabled - data entry fields at runtime

I have a scenerio when my forms are first opened that the user cannot modify
the data. The fields are disabled to prevent them from modifying any of the
data. If a user wishes to modify the data he would be required to click a
"Edit" button which will test permissions or status information of the
record. If the application determines it is ok for the user to modify the
data, it enables the fields where the user now can make changes as
necessary. When the user is finished they can click the save button. The
fields background color is changed to reflect the edit-status of the field.

I have noticed that the read only flag seems to handle this situation,
however I do have one problem. Some of the fields on the form should
remain read-only. If I write a loop to enable/disable all of the controls
on the form then the "read-only" fields are enabled as well. I could write
code for each field but this seems a little backward to me. How is this
type of scenerio usually handled? I thought of adding a new property to
my controls, but then I would be required to inherit every possible user
control. I imagine there has to be a better way so I could continue to use
the standard controls and not have to write code for every control on the
form.

Anyone have any ideas on how this is normally addressed?

Thanks
Dan



Sep 3 '08 #1
5 3005
>... I have noticed that the read only flag seems to handle this situation,
>however I do have one problem. Some of the fields on the form should
remain read-only. If I write a loop to enable/disable all of the controls
on the form then the "read-only" fields are enabled as well. I could
write code for each field but this seems a little backward to me. How is
this type of scenerio usually handled? I thought of adding a new
property to my controls, but then I would be required to inherit every
possible user control. I imagine there has to be a better way so I could
continue to use the standard controls and not have to write code for every
control on the form.
I don't logically see how adding a new property to the controls would solve
this problem, even if you did want to customize them all...

Can you put the controls you wish to toggle inside a Panel control (or
multiple Panels), and leave the read-only fields out of it (them)?

Sep 3 '08 #2
With an additional property the code can be written to Enable the control
ONLY if the the the property is set to true. This property would be set at
design-time and would not
change during runtime.

Then code like the following could test this property. I haven't tested
this code, but this is the idea.

BTW, Thanks Jeff about the idea about using the tag property. It may be the
way I go unless I find a more standarized method.

public void Active(boolean mEnable)
{
foreach(Control oControl in this.Controls)
oControl.Enable d = (mEnable && (oControl.tag == "TRUE"));

}

"Roger Frost" <fr*****@hotmai l.comwrote in message
news:8E******** *************** ***********@mic rosoft.com...
... I have noticed that the read only flag seems to handle this
situation, however I do have one problem. Some of the fields on the
form should remain read-only. If I write a loop to enable/disable all
of the controls on the form then the "read-only" fields are enabled as
well. I could write code for each field but this seems a little
backward to me. How is this type of scenerio usually handled? I
thought of adding a new property to my controls, but then I would be
required to inherit every possible user control. I imagine there has to
be a better way so I could continue to use the standard controls and not
have to write code for every control on the form.

I don't logically see how adding a new property to the controls would
solve this problem, even if you did want to customize them all...

Can you put the controls you wish to toggle inside a Panel control (or
multiple Panels), and leave the read-only fields out of it (them)?

Sep 3 '08 #3
On Sep 3, 9:52*am, "Dan Tallent" <s...@microsoft .comwrote:
With an additional property the code can be written to Enable the control
ONLY if the the the property is set to true. * This property would be set at
design-time and would not
change during runtime.

Then code like the following could test this property. * I haven't tested
this code, but this is the idea.

BTW, Thanks Jeff about the idea about using the tag property. *It may be the
way I go unless I find a more standarized method.

public void Active(boolean mEnable)
{
* * foreach(Control oControl in this.Controls)
* * * * * *oControl.Enabl ed = (mEnable *&& *(oControl.tag == "TRUE"));

}
"Roger Frost" <fros...@hotmai l.comwrote in message

news:8E******** *************** ***********@mic rosoft.com...
>... I have noticed that the read only flag seems to handle this
>situation, however I do have one problem. * Some of the fields on the
>form should remain read-only. * If I write a loop to enable/disable all
>of the controls on the form then the "read-only" fields are enabled as
>well. * I could write code for each field but this seems a little
>backward to me. *How is this type of *scenerio usually handled? * I
>thought of adding a new property to my controls, but then I would be
>required to inherit every possible user control. * I imagine there has to
>be a better way so I could continue to use the standard controls and not
>have to write code for every control on the form.
I don't logically see how adding a new property to the controls would
solve this problem, even if you did want to customize them all...
Can you put the controls you wish to toggle inside a Panel control (or
multiple Panels), and leave the read-only fields out of it (them)?- Hide quoted text -

- Show quoted text -
If you're using the standard BindingSource, you may find a neat way of
doing this to be the solution where you extend the BindingSource and
make it render the control read-only based on underlying data element
it binds to.

Sep 3 '08 #4
>With an additional property the code can be written to Enable the control
>ONLY if the the the property is set to true. This property would be set
at
design-time and would not
change during runtime.

Then code like the following could test this property. I haven't tested
this code, but this is the idea.

BTW, Thanks Jeff about the idea about using the tag property. It may be
the
way I go unless I find a more standarized method.

public void Active(boolean mEnable)
{
foreach(Contro l oControl in this.Controls)
oControl.Enabl ed = (mEnable && (oControl.tag == "TRUE"));

}
Good thinking, and probably the same procedure Jeff had in mind. It seems
much more logical now. I just couldn't wrap my mind around the idea until I
seen this example. Thank you. :) As far as standardized goes, I think the
tag property was created to somewhat standardize non-standard "handling."
Give or take...
...
If you're using the standard BindingSource, you may find a neat way of
doing this to be the solution where you extend the BindingSource and
make it render the control read-only based on underlying data element
it binds to.
But for what it's worth, this is my favorite solution so far...

-Roger Frost

Sep 3 '08 #5

If you're using the standard BindingSource, you may find a neat way of
doing this to be the solution where you extend the BindingSource and
make it render the control read-only based on underlying data element
it binds to.
I am fairly new to C#, but this concept seems interesting. Thanks for idea
I'll check it out.

Thanks again
Dan

Sep 3 '08 #6

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

Similar topics

3
9200
by: Bob Bedford | last post by:
I've this code: function checkdate(FormSubmit){ alert(document.getElementById('Mois').value); if(eval(document.getElementById('Mois'))>0 && eval(document.getElementById('Annee'))>0){ document.forms.getElementByID('SELECTCONSTRUCTOR').disabled = false; //can't reach the control here } else
2
4936
by: Mel | last post by:
i want to diable all submit_buttons untill all my form elements are populated. how can i do that ? thanks
1
4240
by: hortoristic | last post by:
We are using JavaScript to Enable/Disable certain fields on web pages based on business rules. A simple example is if when using an option type tag, and the two options are Yes and No. If YES is selected - enable a field to use the M$ Datepicker. Using the code below works for most of our fields, however the problem is that when the field is re-enabled - it remembers the original date or data prior to it being disabled - despite the...
8
1981
by: newbie | last post by:
hello How can I update more than one tables on the same form? The relationship is one to many from a master table to 3 other related tables. on the form, I have to setvalue for a few fields(colums) in the related tables based on the value I enter in the field from the master table. I kept getting "you have to save the record before you update..." kind of message. Do you have any idea how to handle this? I feel I have to set the master...
3
3792
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76) and they were put onto the form in the numerical sequence. I have given the A's with B & C's on the same line a tag=1; B.tag=2, C,tag=2) I am trying to write 2 modules so that the following occurs (on Form_Current and 'A' Control_Before or...
6
7735
by: Stu Carter | last post by:
Hi, I have an aspx page where some controls are initially disabled by the code-behind 'Page_Load' event. I want these controls to be dynamically enabled when the user checks a checkbox. Because I don't want a post-back, I added some javascript to do this However, using client-side JS, I cannot enable any controls that have been disabled by server-side code. If the control is initially enabled, I can disable/enable it client-side.
6
3792
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after you enter data to the first field on the main form (a VIN#), that is not the case. The SubForm control becomes disabled and will not accept the focus. Dunno why. There's no child/master link fields. They have no settings - at least not in design...
2
1333
by: Pasha | last post by:
Hi friends, I have disabled the textfild by using "disabled" attribute & now i want to enable it on some button click. Can any budy please tell me how should I do this using java script. thank you, Prashant.
5
11815
by: andersond | last post by:
I need to enable or disable a submit button based on the value of a data field stored in a database. I have found working examples of how to enable or disable based on a checkbox; but, I need it to work based on a data field value. I have created a textbox in a hidden area that contains the stored data value. I have set the beginning value of the submit button to disabled. I want the submit button to be enabled if the value in the textbox is...
0
8197
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8589
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5548
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.