473,385 Members | 1,855 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.

Form Threads

ivosilva
Hello to all of you out there!

My problem is as follows:

I have a C# .NET Windows application that uses an ElapsedEventHandler (new thread) to create a new form and display it.

The thing is:

If I use MyForm.ShowDialog() it shows all components the right way, but I would need to place a button (or something like it) to return a DialogResult in order to get the form to close again (I want it to close automatically using MyForm.Close()).

If I use MyForm.Show() the components in the form don't display right, in the place of the components are black rectangles though automatically closes because it doesn't get in a loop like ShowDialog().

I hope you understand my problem.

Thanks in advance!
Oct 29 '06 #1
2 1167
Hope this is what you need.

In Form1

private void btnShow_Click(object sender, EventArgs e)
{
Form2 frmForm2 = new Form2();
this.Hide();
frmForm2.ShowDialog(this);
this.Show();
}

In Form2

private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}


Ambika Praveen
Oct 30 '06 #2
Thanks for your reply, digitalmanic!

But that's not what I want to do. I'll try to explain it better.

I have a main form (Form1) and I use ElapsedEventHandler to call a method that creates a new form (Form2).

But I don't want Form2 to have a button to close, I want it to close automatically after a certain time. I manage to do that all right.

The problem here is that if I use ShowDialog() I cannot close the Dialog until it returns a value.

I'm using Form2.Show() and it works just like I want. It opens, and after a certain time it closes with Form2.Close(). But what happens is that in the place of the Form2 components appear black rectangles (with the shape of the components) but not the components.

If I use ShowDialog() the components are all ok but I have the problem mentioned above: the need of having a button to return a DialogResult.

Thanks again!
Oct 30 '06 #3

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

Similar topics

10
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading....
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
2
by: Sgt. Sausage | last post by:
Problem. Work-around. No issues, just looking to see if I'm the only one that's seen this. I just lost 3 hours (shoulda found it sooner) to the InvokeRequired on a form being somewhat...
1
by: LordHog | last post by:
Hello all, I am a small application that I am developing which will use a few threads. When the user closes the form the threads will remain present until I close them. The Main Form...
13
by: Ioannis Vranos | last post by:
Why in this code the form *does not refresh* when it gets the focus/after some time? #using <mscorlib.dll> #using <system.windows.forms.dll> #using <system.dll> #using <system.drawing.dll>
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
13
by: Edwin Smith | last post by:
I have a form which displays a DataGridView table generated with the VS2005 tools. The database is a Pervasive v.9 with an ODBC driver. The DataGridView works great except when I'm done and I...
1
by: grabit | last post by:
Hi Peoples i have a search page with a form field "subject" on my results page i have a paging routine . the first page lists its 10 records no trouble but when i click the "next" link i get a error...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
0
by: thiago777 | last post by:
Hi! Im still trying to make my application work in an event-driven way. It had worked so far with my threads, but the problem Im having is only when modifying a GUI component from the event handler...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
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: 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?

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.