473,394 Members | 1,709 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,394 software developers and data experts.

how to lock controls on other forms with out closing last form?

i have just started to create a software. in it using menu i goes form one form to another to create an user id and password for ordinary users by admin user. so with out canceling or entering fields in the last form i dont need control to go to previous form or any other form.
Oct 1 '10 #1
1 1457
GaryTexmo
1,501 Expert 1GB
When you open your new form, open it with ShowDialog instead of Show. This should prevent the user from interacting with the parent form until the child form is closed.

Here's an example... built on an application with two buttons.

Expand|Select|Wrap|Line Numbers
  1.     public partial class Form1 : Form
  2.     {
  3.         public Form1()
  4.         {
  5.             InitializeComponent();
  6.         }
  7.  
  8.         private void button1_Click(object sender, EventArgs e)
  9.         {
  10.             ChildForm newForm = new ChildForm();
  11.             newForm.Show();
  12.         }
  13.  
  14.         private void button2_Click(object sender, EventArgs e)
  15.         {
  16.             ChildForm newForm = new ChildForm();
  17.             newForm.ShowDialog();
  18.         }
  19.     }
  20.  
  21.     public class ChildForm : Form
  22.     {
  23.         public ChildForm()
  24.         {
  25.         }
  26.     }
Clicking the first button opens the child form and lets you interact with the parent form, Form1. Clicking the second button opens the child form with ShowDialog, which prevents you from interacting with Form1.

Hope that helps!
Oct 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Eric Cadwell | last post by:
We're running Load Runner to test a large 1.0 based WinForms application. I'm getting the following exception when opening and closing a form 400 - 450 times. The form contains several controls and...
5
by: Peter yeshew | last post by:
Is it possible to forbid closing the form through the File- Close menu ? On my form i have a command button called CmdDeleteInvoice. When this command button is visible ,i want to forbid the user...
2
by: Composer | last post by:
One form in my Access 2000 mdb causes a crash whenever I close it. The crash is of the type where I get a "Please tell Microsoft about this problem". Easy, you think! Well, here are the things...
1
by: Dan | last post by:
Is it possible to access controls on other forms when using managed C++? In VB, it was a simple matter of declaring the form as global, but this is apperently not possible when using managed code....
5
by: smhaig | last post by:
In a vb 6 app in the activate event I was able to do some testing and if something failed, I was able to exit the form and return to the caller form. I have tried everything and searched web but...
5
by: Simon Verona | last post by:
I have an application with a menu system which creates a new thread when a menu item is selected - some of these other threads may open a form for user interaction. Before the menu system is...
3
by: Bob | last post by:
I haver a user login form (winforms app using vs2005 in VB.NET). After succesfull validayion of user I want to open a first form and close the loging form that was used, If I write If...
6
by: Gerry Abbott | last post by:
Hi all, Im opening a bound form, targetForm from other forms, but want close it if there's no records in it. Would be good if I could do this from within the targetForm, since I open it from...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
2
by: yang from china | last post by:
Exactly I create a main form and a sub form.There are several pictures on the main form. what I want to do is when I select one picture in the main form,I want the sub form display that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
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...
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:
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...

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.