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

ShowDialog problem

28
Hello Im using show dialog.. this code

Expand|Select|Wrap|Line Numbers
  1. settings f = new settings();
  2.  
  3. f.ShowDialog();
  4. this.Enabled = false;
  5. if (f.ShowDialog() == DialogResult.OK)
  6. {
  7. load_reg_key();
  8. this.Enabled = true;
  9. }
  10. f.Close();
and when i click on button..

Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. this.DialogResult = DialogResult.OK;  
  4. this.Close();
  5. }
then form close and imediatly show again.. After second click on button . form closed and program resume... Where i making problem ?
Sep 16 '09 #1
3 5654
GaryTexmo
1,501 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. f.ShowDialog();
  2. this.Enabled = false;
  3. if (f.ShowDialog() == DialogResult.OK)
That's your problem right there... you're calling ShowDialog() twice. When that method is called it actually shows the dialog, and returns the result. Remove the first ShowDialog() call and it should work just fine for you.
Sep 16 '09 #2
tlhintoq
3,525 Expert 2GB
That's because you are telling it to show the dialog twice: Once in line 3 and again in line 5.

Try something more like this.

Expand|Select|Wrap|Line Numbers
  1. settings f = new settings();// I presume this is a form you made
  2. DialogResult MyResult = f.ShowDialog();// Code stops here until the dialog closes
  3. // Now you have recovered the result from the dialog into a variable you can work with.
  4. if (MyResult == DialogResult.OK)
  5. {
  6.      LoadRegKey();
  7.      this.Enabled = true;
  8. // Hmmm... Here "this" would be the main form. 
  9. // if 'this' was previous disabled then how did you call the settings dialog?
  10. }
  11.  
Sep 16 '09 #3
BbEsy
28
many thanks for your fast reply.. It works :]]]
Sep 16 '09 #4

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

Similar topics

3
by: Richard L Rosenheim | last post by:
I would like to detect when a form is invoked as the result of a ShowDialog call. Anyone have any ideas or suggestions on how to do that? TIA, Richard Rosenheim
2
by: Bill Burris | last post by:
When you crate a Windows application the wizard adds a line like: Application.Run( new MyMainForm() ); Out of curiosity I replaced this with: MyMainForm myForm = new MyMainForm();...
5
by: Josh Golden | last post by:
3 forms. form 1, when button clicked instantiates form 2 which opens but is not shown. form 2 instantiates form 3 as showdialog. form 3 finishes, raises an event that form 2 catches. during the...
4
by: Dennis Sjogren | last post by:
Greetings! First, I'm not 100% sure where to post this question. I use VB.NET for this project, but it's really a design question (a question on which method to use when solving this problem). ...
6
by: Samuel R. Neff | last post by:
I'm having weird results with a form that is already displayed modally (via ShowDialog) displaying a second form via ShowDialog. The last form is not modal even though it's called with ShowDialog....
8
by: WvH | last post by:
Hi, When I create a new application, with just one button, then this code works as expected: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
2
by: **Developer** | last post by:
I have a little more info about this problem I can't seem to solve! I know it'll take a minute to study the lising but if you like to sove puzzles there is one there. I have a Form (FV&C)...
1
by: SammyBar | last post by:
Hi all, I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when activating the barcode scanner from a window. The problem is related to the Activated event of the form which...
3
by: =?Utf-8?B?RGF2ZVA=?= | last post by:
I am having a problem in a .NET 2.0 / Visual Studio 2003 application. Most of the time, the app works fine. But occasionally, I get to the point where I execute this code: ...
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
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?
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
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,...
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...

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.