C# Question

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

pcpro17

Thread Starter
Joined
Oct 9, 2006
Messages
469
Hello. I'm relatively new to C#. I've got a C# application that I inheritted from the previous guy here, and I need to make some modifications to it. I've added an About box/form to the Help menu. Does anyone know how/where I can link the About option in the Help menu to the About box, so that it will appear? Where is that kind of launch code usually located?

Also, this application has a bunch of auxillary windows that launch when it starts. Where is this code usually located. I recall that MFC had a function for Paint. Is this does the same way with C#?

I am using C# 2005 Express Edition.

Thanks. :)
 
Joined
Sep 24, 2007
Messages
91
I think you've added an About menu item to the Help menu. Just select your About menu item and doubleclick on it. It will create a method which will execute when you click on the menu item.
Simply instanciate your About box and add the .Show() or .ShowDialog() code to this method.

Auxillary windows: Check Program.cs and OnLoad() methods for them.
 

pcpro17

Thread Starter
Joined
Oct 9, 2006
Messages
469
Hello artur. Thank you for the assistance. I can kind of see what you are talking about. However, I'm still having a little trouble. Maybe some additional details will help. (Unfortunately, I cannot give out too much due to legal restrictions...)

In frmMain.cs I have this code:
Code:
        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
//            AboutBox1.ActiveForm.ShowDialog();
        }
And in AboutBox1.cs there is this:
Code:
        private void AboutBox1_Load(object sender, EventArgs e)
        {
//            ShowDialog();
        }
I'm not certain that I have either of these setup correctly. Any thoughts?

Also, I'm having a little trouble finding the initialization code you mentioned. Program.cs contains only some auto-generated code:
Code:
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
    }
And, OnLoad does not appear anywhere in the project files. Any other thoughts? Might it be a property in these forms?

Thanks. :)
 
Joined
Jun 6, 2003
Messages
125
Try This
Code:
        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
             AboutBox1 = new AboutBox1();
             AboutBox1.ShowDialog();
        }
 
Joined
Sep 24, 2007
Messages
91
pcpro17 said:
Hello artur. Thank you for the assistance. I can kind of see what you are talking about. However, I'm still having a little trouble. Maybe some additional details will help. (Unfortunately, I cannot give out too much due to legal restrictions...)

In frmMain.cs I have this code:
Code:
        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
//            AboutBox1.ActiveForm.ShowDialog();
        }
And in AboutBox1.cs there is this:
Code:
        private void AboutBox1_Load(object sender, EventArgs e)
        {
//            ShowDialog();
        }
I'm not certain that I have either of these setup correctly. Any thoughts?

Also, I'm having a little trouble finding the initialization code you mentioned. Program.cs contains only some auto-generated code:
Code:
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
    }
And, OnLoad does not appear anywhere in the project files. Any other thoughts? Might it be a property in these forms?

Thanks. :)

The '//' means the line is a comment, so the first two methods don't do anything.
The
Code:
Application.Run(new frmMain());
line means the first form appearing on the screen is a new instance of frmMain class, what is actually a Form.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top