From a C# program I have selected a specific SQL database record which I want to display on a Windows form. However, even though I wish to display all the fields in the database record for visual confirmation that I do indeed have the correct record there is only one field I wish to change. So, to prevent accidental updating of all other fields, I wish to protect these fields and only allow the user access to the one field I want updated. Can anyone point me in the right direction?
Thanks.
Depends on how you're displaying these fields. If you're just using normal GUI controls, use Labels to display the read-only fields. You can't edit a label. Or use a TextBox, and set it's ReadOnly property to true.
If you're using a DataGrid, there are ways to set columns to read only. You have to manually add the columns though, not auto-generate them.
6 1771
Depends on how you're displaying these fields. If you're just using normal GUI controls, use Labels to display the read-only fields. You can't edit a label. Or use a TextBox, and set it's ReadOnly property to true.
If you're using a DataGrid, there are ways to set columns to read only. You have to manually add the columns though, not auto-generate them.
Thanks Curtis, I'll set the ReadOnly property. One other question, how do I close the current form and return to a previous calling form?
Joe
Again, depends. How did you create the new form (Show or ShowDialog)? Did you close the old form when you opened the new one? Hide it? Nothing?
You can call .Close() on a form and it will close.
I did a .Show, and I didn't do anything with the old form. It was only after googling that I realised it might be a good idea to close it. On a button1_Click event I tried form1.Close(); but it gave me an error "An object reference is required for the non-static field, method, or property..." Also, I'm intrigued by the "Hide" method you mentioned... so much new stuff to learn :-) Anyway, once again many thanks, I'm amazed at how many nice people there are in the IT fraternity, gives me hope in humanity. Joe
Well, if you want to hide the form, you would use .Hide.
The problem is, if you're using Show, then your Form1 has no idea when it should show itself. You have to use events. Subscribe to the child form's Closed event, and call "this.Show()" to bring it back.
Thank you, not 100% sure how to do that but now you have pointed me in the right direction it's amazing what one can find out with GOOGLE. :-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: LaurenW |
last post by:
Hi folks,
I just discovered that I have a table with a bunch of text fields that
ALL have the "Allow Zero Length" property set to "No", which is
apparently the default when you create a new text...
|
by: John Baker |
last post by:
Hi:
I am having a problem making the impact a field property change in a table trickle through
to a report. Between the table and the report are numerous queries and sums. I have
changed the...
|
by: Bruce LeMond |
last post by:
To my understanding the data key field property in the web
form datagrid is used for finding the correct record in
the data set for updating. It looks like only one field
could be specified, but...
|
by: MilanB |
last post by:
Hello
What is the best way (or does it exists a way at all) to protect WinForm
application
from decompiling IL.
Can it be full compiled yo windows native before distribution.
And what is...
|
by: Lauren Wilson |
last post by:
Owning your ideas: An essential tool for freedom
By Daniel Son
Thinking about going into business? Have an idea that you think will
change the world? What if you were told that there was no way...
|
by: naseesalih |
last post by:
i write code for protect selection of field. its working properly in explorer but not working in Netscape or other browser. pls send any one who know how to write netscape
function...
|
by: zlfcn |
last post by:
Hi all,
In java, if a field is Integer type, we can assign it to null indicating
that this field has not been set yet. How can we achieve that in C#? In C#,
"int" is struct, we cannot set it to...
|
by: questionit |
last post by:
If we have 2 tables, which are linked to each other
And i want to change property of a field in one of the tables i.e Max Character Length, etc
how would i do it - becasue Ms Access doesn't us...
|
by: Tirisano |
last post by:
I am getting the following error in a ASP.Net application.
A field or property with the name 'ContactPerson' was not found on the selected datasource.
We are running SQL Server 2000. We are...
|
by: Clive Dixon |
last post by:
Is there any way in code snippets that I can have a single replacement field
from which I can generate both a field name and a property name along the
standard lines, i.e. camle case & Pascal case...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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,...
|
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...
| |