dcsimg
Results 1 to 8 of 8
  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,750

    Resolved [RESOLVED] Form not showing up in intelisense?

    I have a Windows Application that contains a MDI form with several child forms. In a MenuItem Click Event I am trying to show a new child form, however, when I try to reference the form...it doesn't show up in the intelisense. I'm new to C# programming.

    Thanks,
    Blake

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,623

    Re: Form not showing up in intelisense?

    Check for errors in the form. Usually when I see that happening - and this is in both C# and VB.NET it's because there's a bug in the form that prevents it from compiling.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,750

    Re: Form not showing up in intelisense?

    But it does compile and run?
    Blake

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,907

    Re: Form not showing up in intelisense?

    How exactly are you trying to reference the form? If you add another form to your project can you see that in the same Intellisense list? These questions are relevant regardless of the language.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,907

    Re: Form not showing up in intelisense?

    I just created a new project, made the default form an MDI parent, added a MenuStrip with File -> New menu items. I added a second form, handled the Click event of the New menu item and added this code:
    csharp Code:
    1. private void newToolStripMenuItem_Click(object sender, EventArgs e)
    2. {
    3.     var childForm = new Form2();
    4.  
    5.     childForm.MdiParent = this;
    6.     childForm.Show();
    7. }
    Does that work for you? Are you maybe trying to use the default instance of the form, which is a feature specific to VB and thus not possible in C#?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,750

    Re: Form not showing up in intelisense?

    I figured it out. I did not realize that I the MDI Form needs to reference the project itself, which is SchoolTrack. So I had to insert "using SchoolTrack" statement in my MDI Form code.
    Blake

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,907

    Re: Form not showing up in intelisense?

    Quote Originally Posted by blakemckenna View Post
    I figured it out. I did not realize that I the MDI Form needs to reference the project itself, which is SchoolTrack. So I had to insert "using SchoolTrack" statement in my MDI Form code.
    That's not a reference to the project. That's an import of the namespace. They are two different things. Just as in VB, you have to let the compiler know the fully-qualified name of every type you use in code. You can use the fully-qualified name every time, in which case you could have selected first the namespace and then the type from Intellisense.

    Alternatively, you can import the namespace and just use the type name in code. In VB, you can put an Imports directive at the top of a code file to import a namespace into that specific file. In C#, the equivalent is a 'using' directive. In VB, you can also import namespaces at the project level, which is done on the References page of the project properties. There is no equivalent to that in C#.

    Your issue is probably that you are used to namespaces being imported at the project level in VB and so you don't realise that they are. Without those project-level imports, you'd need Imports statements at the top of every VB code file, just as you have 'using' statements at the top of every C# code file.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,750

    Re: [RESOLVED] Form not showing up in intelisense?

    jmc,

    Your correct...this is what I was thinking.

    Your issue is probably that you are used to namespaces being imported at the project level in VB and so you don't realise that they are. Without those project-level imports, you'd need Imports statements at the top of every VB code file, just as you have 'using' statements at the top of every C# code file.
    Blake

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.