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

Display a dialog once my main form is showing?

I have a C# form application. Once my main window is showing I want to
pop-up a login type dialog. What event would I trap to affect this? I
tried handling the form load but the main form window is not yet visible
then.

Thanks!

Grant Schenck
Nov 17 '05 #1
4 2991
Grant,

You will want to use the Activated event to handle this. First, you
have to define a flag in your class:

// Default to false, indicating that the form is not activated for the first
time.
private bool firstTimeActivation = true;

Then, you have to handle the Activated event:

// If the flag is true, then show your login form.
if (firstTimeActivation)
{
// Set the flag to false here. The reason for this is that when
// your login form is closed, this form will activate again, and
// this will be called again before you exit this block for the first
// time.
firstTimeActivation = !firstTimeActivation;

// Show your login form here.
}

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Grant Schenck" <sc******@optonline.net> wrote in message
news:eM*************@TK2MSFTNGP09.phx.gbl...
I have a C# form application. Once my main window is showing I want to
pop-up a login type dialog. What event would I trap to affect this? I
tried handling the form load but the main form window is not yet visible
then.

Thanks!

Grant Schenck

Nov 17 '05 #2
There are many events which are fired while the form is getting loaded, painted:

Activated, GotFocus, LayOut.... Please consult MSDN for type Form and have a look at the Event section.

HTH, Metallikanz!

"Grant Schenck" <sc******@optonline.net> wrote in message news:eM*************@TK2MSFTNGP09.phx.gbl...
I have a C# form application. Once my main window is showing I want to
pop-up a login type dialog. What event would I trap to affect this? I
tried handling the form load but the main form window is not yet visible
then.

Thanks!

Grant Schenck

Nov 17 '05 #3
Thank you!

That did the trick.

Grant Schenck

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:#m**************@TK2MSFTNGP10.phx.gbl...
Grant,

You will want to use the Activated event to handle this. First, you
have to define a flag in your class:

// Default to false, indicating that the form is not activated for the first time.
private bool firstTimeActivation = true;

Then, you have to handle the Activated event:

// If the flag is true, then show your login form.
if (firstTimeActivation)
{
// Set the flag to false here. The reason for this is that when
// your login form is closed, this form will activate again, and
// this will be called again before you exit this block for the first
// time.
firstTimeActivation = !firstTimeActivation;

// Show your login form here.
}

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Grant Schenck" <sc******@optonline.net> wrote in message
news:eM*************@TK2MSFTNGP09.phx.gbl...
I have a C# form application. Once my main window is showing I want to
pop-up a login type dialog. What event would I trap to affect this? I
tried handling the form load but the main form window is not yet visible
then.

Thanks!

Grant Schenck


Nov 17 '05 #4
Hi,

It does depend if you want to have the back window visible or not, if not
use Load ( the good thing of this one is that it fires only once ) if you
want it visible you could follow Nicholas's suggestion.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Grant Schenck" <sc******@optonline.net> wrote in message
news:eM*************@TK2MSFTNGP09.phx.gbl...
I have a C# form application. Once my main window is showing I want to
pop-up a login type dialog. What event would I trap to affect this? I
tried handling the form load but the main form window is not yet visible
then.

Thanks!

Grant Schenck

Nov 17 '05 #5

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

Similar topics

1
by: Dalan | last post by:
I designed a dialog box with a combo to select individual vendors from a form and its related data for print ouput. Though the dialog box seems to work okay, I apparently do not have the filtering...
0
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record...
3
by: RAllsopp | last post by:
I have a client who would like to have several pictures associated with one system. I have read about storing only the pathname to save OLE overhead and have set-up a form for my client to...
4
by: Alexander | last post by:
Hi, I have written a program that takes on some operations much more time than I expected. As I have seen users clicking wildly on the screen to make something happen, I want to follow the...
5
by: John | last post by:
Hi How can I show a dialog from within the main form? frmdialog.show? Thanks Regards
7
by: Peter | last post by:
I have a primary form named frmMain. During some extended data pulls I launch another Dialog Form named frmUpdating. How do I keep the frmUpdating centered on the frmMain if a user moves the...
1
by: | last post by:
Hi all, I would like to call a dialog form from the main form, just after the main form is loaded. however, if i put the code at either Form_Load or FormActivate, they both cannot achieve it,...
4
by: forest demon | last post by:
i've seen previous posts somewhat related to this, so i apologize if this is redundant. I have a main form with separate threads. When showing a dialog like <dialog>.ShowDialog(), it functions...
0
by: =?Utf-8?B?a20=?= | last post by:
I've got a simple C# app built in VS2005. When I click a menu item a modal form opens and performs a lengthy operation in the Load event handler to populate a text control, so it takes a few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.