Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4381188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:37:06+00:00 2026-05-21T12:37:06+00:00

I am exploring the EnvDTE library, and building a form generator. I have successfully

  • 0

I am exploring the EnvDTE library, and building a form generator.

I have successfully added controls to a form, however, the controls’ codes are not added to the form designer (formname.Designer.cs), and that is a problem if I want to add event handlers, because the controls are not yet declared.

When I double-click a button, which adds the event handler to the button in the form designer, that adds all of the controls in the form designer. So any update should do it.

Here’s how I’m adding the controls:

//this ProjectItem (itemFrom) is a reference to a recently added form,
//and its only window is my form

Window myWindow = itemForm.Document.Windows.Item(1);

IDesignerHost myDesigner = (IDesignerHost)myWindow.Object;

IComponent comp = myDesigner.CreateComponent(typeof(Button), "MyNewButton);

Question:
How do I programmatically update the form designer (with EnvDte or VS API) in order to get references to my controls and adding event handlers to them ?

One thing that’s weird: I’ve found a couple of tutorials on adding controls to forms through VS Add-Ins, but none of them has mentioned this problem..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:37:06+00:00Added an answer on May 21, 2026 at 12:37 pm

    I have found the answer to my questions, but I’m still struggling with some colateral issues of it:

    IEventBindingService myIEventBindingService = (IEventBindingService)myDesigner.GetService(typeof(IEventBindingService));
    myIEventBindingService.ShowCode();
    //obs: myDesigner is of type IDesignerHost
    

    The colateral issues:

    1) The code is actually shown to the user. Which is not desired.
    2) You cannot run it more than once.

    The reason you’d want to run it more than once, is that this update is necessary in order to be able to actually add code to the event handlers, as they cannot be found unless the designer is updated. This means that every piece of code has to be added after every event handler has been added. So no simple methods to add them.

    This way I had to add all the event handlers, update the designer, get references to event handlers through their names and just then write whatever they do.

    I’m eventually going to fix this (EnvDTE is poorly documented), and then I’ll update this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started exploring Maven, but I feel a bit overwhelmed of all
I have an Internet Explorer only web application. I'm exploring what we can do
I am exploring Django with MySQL & have a few things that I wanted
We have just started exploring what required for internationalizing our applications. One thing I'm
while exploring jQuery I came up with the following weird script. I don't see
I'm exploring the possibility of writing an application in Erlang, but it would need
I've been exploring different strategies for running integration tests within some Nant build scripts.
I'm exploring the XML -> XSLT -> HTML meme for producing web content. I
I'm thinking about exploring the idea of having our client software run as a
I'm exploring the possibility of running a Java app on a machine with very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.