Problem in inherited form (VS.Net 2010, WinForms).
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Problem in inherited form (VS.Net 2010, WinForms).

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    79

    Question Problem in inherited form (VS.Net 2010, WinForms).

    I built a ClassLibrary where I have created my custom form component (let's say MyForm) that inherits from the Form class. I added the ClassLibrary to my actual WinForms project. Now when I add an inherited form based on MyForm to my project through the 'Add New Item' dialog box for the first time, its Text property remains blank by default. But when you add a standard form to a project, its Text is set to its Name by default. This is what my requirement is. I even tried to set the Text property in MyForm's constructor, yet it isn't working. How to solve this?

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,987

    Re: Problem in inherited form (VS.Net 2010, WinForms).

    Think it might help to share what you've tried, so we don't have to GUESS!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2008
    Posts
    79

    Question Re: Problem in inherited form (VS.Net 2010, WinForms).

    When I add an inherited form to my project from MyForm through the 'Add New Item' dialog box, I enter the name of the form that I want to add in the 'Name' TextBox of the 'Add New Item' dialog box and click 'Add'. Now when a new standard form is added to a project in the same way, its Text property holds the name of the form itself by default. That's what is not happening when I add the new form based on MyForm.
    One thing to say, I'm just setting a default backcolor of the form in the inherited class and didn't override the Text property. No more complex code is in there.
    It seems the naming of forms is done by the design IDE. It is not part of the Form Class. That's when the Text property is set by default.
    Feel free if I'm not understandable.

  4. #4
    Join Date
    Sep 2008
    Posts
    79

    Re: Problem in inherited form (VS.Net 2010, WinForms).

    The naming of forms is done by the design IDE. It is not part of the Form Class. The IDE sets the name of a form to its text by default when it is created from the 'Add New Item' dialog box. But it's not done in case of inherited forms. Seems I have to set a default text in MyForm's constructor.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center