locked
About Box form trouble RRS feed

  • Question

  • Hello,

    I'm a total noob in learning VS C# coming from an embedded C background. The transistion to OOP concepts has been quite challenging when my head is so focused on microcontroller hardware.

    I have 2 questions.

    Question #1

    I'm currently developing a simple Forms application using VS C# Express as my learning tool with reasonable success. However I'm experiencing difficulty with implementing an "About Box" form. I have implemented a button in my main app form and added a new form item "about box". Going into the About box properties and editing each element I have successfully have added the text I wish to display and even added an image as well.

    I then added the following code inside the Form.cs member for the button:

            private void btn_About_Click(object sender, EventArgs e)
            {
                AboutBox1 myAbout = new AboutBox1();
                myAbout.ShowDialog();
            }
    

    When running my application in debug or w/o debug and click on my about button, the about box pops up correctly but does not display any of entered text.  All I get is what appears to be default text "WindowsFormsApplication1 Version 1.0.0.0 copyright 2010" ect ect. The intersting part is the image I wish to display beside the about text is the only thing correct.

    I'm obviously missing something here and would kindly ask if someone can explain what it is I need to to to fix this. Have I corrupted something or is this normal crippled function in VS C# Express?

    Question #2

    What would be the best way to incorporate a small help file into my application where it doesn't require an external document? Basically can I incorporate it within the application *.exe?

    thx


    • Edited by Sparky1039 Tuesday, December 20, 2011 8:55 PM typo
    Tuesday, December 20, 2011 8:53 PM

Answers

  • Thanks that did the trick. In efforts to learn would you offer an explanation why this code was causing the problem? It would be nice to understand the basis on how the problem was created in the first place. thx


    Hi Sparky1039,

    Welcome to the MSDN Forum.

    If you create the AboutBox from Visual Studio Template, all the CopyRight, Version,application Name are read from the AssemblyInfo.cs:

    So, change it manually in the onLoad event is not good here.

    Best Regards


    Neddy Ren[MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Neddy Ren Monday, January 2, 2012 8:33 AM
    Thursday, December 22, 2011 9:46 AM
  • Hi Sparky1039,

    For your second question, in the C# Windows Form, the HelperProvider will help you to achieve that:

    HelpProvider:

    http://msdn.microsoft.com/en-us/library/system.windows.forms.helpprovider.aspx 

    Best Regards


    Neddy Ren[MSFT]
    MSDN Community Support | Feedback to us
    • Proposed as answer by Neddy Ren Monday, January 2, 2012 8:33 AM
    • Marked as answer by Neddy Ren Monday, January 2, 2012 8:33 AM
    Thursday, December 22, 2011 9:49 AM

All replies

  • Your myAbout form should show exactly as it appears in the AboutBox1 designer.
    Tuesday, December 20, 2011 9:52 PM
  • Hi John,

    That is the odd part, it doesn't, hence my forum query. Looking through the code for the AboutBox1.Designer.cs I see the proper text for what I want displayed. However, when I run the app the text is VS default. Weird. Im thinking something is corrupted or I have failed to set an attribute somewhere. I've tried deleting all of the aboutBox form stuff and starting over from scratch but the result is the same.

    If I can't get this resolved I may just make my own "about" form and be done with it.

    Tuesday, December 20, 2011 10:12 PM
  • When you look at the AboutBox1 in its designer is it as you want it? 

    I don't understand this:  "Looking through the code for the AboutBox1.Designer.cs I see the proper text for what I want displayed."

    Is it displayed or not?

    Tuesday, December 20, 2011 10:18 PM
  • When you look at the AboutBox1 in its designer is it as you want it? 

    I don't understand this:  "Looking through the code for the AboutBox1.Designer.cs I see the proper text for what I want displayed."

    Is it displayed or not?


    Yes to the first, no to the second.

    Here are a few screenshots. Below is a code fragment showing the text entered in the "copyright" field when editing the aboutbox form.

    Below is a screen shot of the designer form (top) and what is displayed when running the application (bottom).

    Could this issue have anything to do with namespace naming?

    Wednesday, December 21, 2011 12:02 AM
  • Comment out the code in the load event of the AboutBox1.


    I think you got the message, but I was looking at a VB AboutBox.  For C#, comment out everything but the InitializeComponent() call in the constructor.  This code runs after the InitializeComponent call which is the designer code.  Thus it overwrites the designer.

    • Edited by JohnWein Thursday, December 22, 2011 10:01 AM
    Wednesday, December 21, 2011 5:30 AM
  • Thanks that did the trick. In efforts to learn would you offer an explanation why this code was causing the problem? It would be nice to understand the basis on how the problem was created in the first place. thx
    Wednesday, December 21, 2011 4:32 PM
  • The code in the Load event runs after the designer code, thus it overwrites the what the designer wrote.
    Wednesday, December 21, 2011 4:35 PM
  • Interesting. This sounds to me like a compiler flaw on how it assigns priority to what gets displayed. One would think the text entered via the from would take precedence.  Thanks for the help.

    Wednesday, December 21, 2011 4:44 PM
  • Runtime always takes precedence over design time.  The state of any program is the result of the last code to run.
    Wednesday, December 21, 2011 4:49 PM
  • Thanks that did the trick. In efforts to learn would you offer an explanation why this code was causing the problem? It would be nice to understand the basis on how the problem was created in the first place. thx


    Hi Sparky1039,

    Welcome to the MSDN Forum.

    If you create the AboutBox from Visual Studio Template, all the CopyRight, Version,application Name are read from the AssemblyInfo.cs:

    So, change it manually in the onLoad event is not good here.

    Best Regards


    Neddy Ren[MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Neddy Ren Monday, January 2, 2012 8:33 AM
    Thursday, December 22, 2011 9:46 AM
  • Hi Sparky1039,

    For your second question, in the C# Windows Form, the HelperProvider will help you to achieve that:

    HelpProvider:

    http://msdn.microsoft.com/en-us/library/system.windows.forms.helpprovider.aspx 

    Best Regards


    Neddy Ren[MSFT]
    MSDN Community Support | Feedback to us
    • Proposed as answer by Neddy Ren Monday, January 2, 2012 8:33 AM
    • Marked as answer by Neddy Ren Monday, January 2, 2012 8:33 AM
    Thursday, December 22, 2011 9:49 AM