1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

C# Question

Discussion in 'Software Development' started by pcpro17, Oct 26, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. pcpro17

    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. :)
     
  2. artur02

    artur02

    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.
     
  3. pcpro17

    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. :)
     
  4. metweek

    metweek

    Joined:
    Jun 6, 2003
    Messages:
    125
    Try This
    Code:
            private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
            {
                 AboutBox1 = new AboutBox1();
                 AboutBox1.ShowDialog();
            }
    
     
  5. artur02

    artur02

    Joined:
    Sep 24, 2007
    Messages:
    91

    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.
     
  6. Sponsor

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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/643889

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice