Phil,
I understand that event-handling should be done in the Form which it
was created. However is it possible for the Exec method in the
Connect.cs class to listen for commands (i.e. button_Click) on a
User Control? Should the example code below work?
public void Exec(string commandName...
{
...
if(commandName == "MyAddin.MyUserControl.btnMyButton_Click)
{
/* Code to close MyUserControl goes here*/
/* Code to open AnotherUserControl goes here*/
}
...
..
Thanks
--- In vsnetaddin@yahoogroups.com, "Phil Jollans" <phil@...> wrote:
>
> Hi Ngo,
>
> this isn't so much an Add-In problem, as a general .NET
programming question.
>
> If the button is on a UserControl, then the handler for the button
click event should go in that UserControl. Just double click on it
in the designer window and it will add the handler function.
>
> Phil
>
> ----- Original Message -----
> From: ngo_udhs
> To: vsnetaddin@yahoogroups.com
> Sent: Monday, January 14, 2008 7:28 PM
> Subject: [vsnetaddin] Handling Events from ToolWindows in the
Connect.cs Class
>
>
> I've created a add-in in VS.NET 2005 using C#.
>
> The add-in loads a tool window OnConnection and it contains a
User
> Control with input text fields and a "Login" button.
>
> After the user clicks on this button, I want the User Control to
> close and open another User Control after.
>
> I was thinking I can have the Exec function in Connect.cs to
listen
> for events such as a button_click however I had no such luck.
Would
> this be the correct approach?
>
> I've googled all over, but had no luck finding any advance
articles
> on handling ToolWindow events.
>
> Any help is greatly appreciated.
>
> Thanks
>
> (The code below will explain a little more of what I'm trying to
do.)
>
> public void Exec(string commandName, vsCommandExecOption... )
> {
> handled=false;
> if(executeOption ==
> vsCommandExecOption.vsCommandExecOptionDoDefault)
> {
> if(commandName == "MyAddin.Connect.MyAddin")
> {
> handled = true;
> return;
> }
> /* Clicking the "Login" button on the User Control form does
> not execute this command. Why?*/
>
> if(commandName == "MyAddin.LoginUserControl.btnLogin_Click)
> {
> /* Code to close LoginUserControl goes here*/
> Debug.Print("=========Login button clicked!!=========");
> /* Code to open another User Control goes here*/
> ....
> }
> }
> ...
> ..
> /* End of code snippet */
>
>
>
>
>
> [Non-text portions of this message have been removed]
>