How to make a button on a application open a register page in Visual Studio - visual-studio

I'm making an application group chat in Visual Studio learn a bit more, all is good so far, so I've made my design and coded most of what I need, I have added a Button and called it Register now what I want is when people click it it will open another page or some type of menu where people can type there information in to register, I thought somthing like this or is this so wrong.
private void RegisterButton_Click(object sender, RoutedEventArgs e)
{
//what gose here
}

You can use Response.Redirect inside the button click to do this.
Refer to these articles:-
https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx
https://support.microsoft.com/en-sg/kb/307903

Related

White/TestStack UI Automation - clicks app button opens a browser, how do I check the url?

I am currently using White/TestStack to test a windows app.
There are scenarios that requires user to click on links to open pages on browser. How do I check the hyperlink is working?
Old question but in case somebody else looking for an answer:
If you check in the White GitHub repository and you browse the UITests and the control tests, you will find the Hyperlink control test. In the sourcecode, you will find several tests according the type of framework used.
The simplest one:
var hyperlink = MainWindow.Get<Hyperlink>("LinkLabel");
hyperlink.Click(10, 10);
Assert.That(hyperlink.HelpText, Is.EqualTo("Hyperlink Clicked"));
The test is based on the used of code-behind for the MainWindow:
private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
{
AutomationProperties.SetHelpText(LinkLabel, "Hyperlink Clicked");
}
XAML code of the hyperlink in the MainWindow
<TextBlock x:Name="LinkLabelContainer">
<Hyperlink x:Name="LinkLabel" Click="Hyperlink_OnClick">Link Text</Hyperlink>
</TextBlock>
So you can used the same method.
TL;DR
You can link the Click() event of your hyperlinks to a method in code behind which update the automation property HelpText of the hyperlink with a specific value for the clicked event.
So in your tests, you will just have to perform the click and then check the automation property value.

How can my Outlook Plugin (VSTO) detect when Outlook is fully loaded?

Thanks for looking.
I am developing an Outlook plugin that needs to prompt the user to log in upon loading of Outlook. I am currently accomplishing this by hooking into the Startup event of ThisAddIn.
Problem
Unfortunately, the log in dialog is displaying before Outlook is fully loaded so it appears to the user as if Outlook is not loading and they are being forced to log in for the plugin.
Question
Is there an event that can be subscribed to from within my plugin code that will only fire after Outlook has fully loaded and is being displayed to the user?
Related links
Ready event in Microsoft Outlook 2010? (The answer regarding use of StartupComplete event via IDTExtensibility2 looks promising but I am not sure how to implement it. Any advice there is appreciated as well.)
I have tried. . .
I have tried the following but this causes the dialog to launch too soon:
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//Fire 3rd party code to launch log-in dialog here
}
Check if Application.Explorers.Count > 0. If yes, proceed. Otherwise subscribe to the Explorers.NewExplorer event and run your code in that event handler when an Explorer is shown.

Infragistics grid in win desk top application, design view is not available for viewing

I have a weird situation with Infragistics grid in desktop windows application. It is Visual Studio 2010.
I have several grids placed in one form control. It worked fine and I was able to see both Code Behind view and Designer view to make modifications. Then several other developers worked with the same control. It still runs fine, no problem. I still can see and modify code behind. But I can not access and view design view for some reason. It just gives me the error message :
Key already exists Parameter name: Key
Here is call stack:
at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject)
at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key, IKeyedSubObject ignoreObject)
at Infragistics.Shared.KeyedSubObjectsCollectionBase.InternalAdd(IKeyedSubObject obj)
at Infragistics.Win.UltraWinGrid.ColumnsCollection.InternalAdd(UltraGridColumn column)
at Infragistics.Win.UltraWinGrid.UltraGridBand.InitColumns(UltraGridBand[] oldBands)
at Infragistics.Win.UltraWinGrid.UltraGridBand.InitListManager(BindingManagerBase bindingManager, String dataMember, UltraGridBand[] oldBands)
at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager)
at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated()
at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
at Infragistics.Win.UltraWinGrid.UltraGridBase.VerifyDataSourceAttached()
at Infragistics.Win.UltraWinGrid.UltraGridBase.DesignTimeDataSourceInitialization()
at Infragistics.Win.UltraWinGrid.UltraGridBase.OnDesignerHostLoadComplete(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.ComponentModel.Design.DesignerHost.OnLoadComplete(EventArgs e)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.Serialization.IDesignerLoaderHost.EndLoad(String rootClassName, Boolean successful, ICollection errorCollection)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnEndLoad(Boolean successful, ICollection errors)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnEndLoad(Boolean successful, ICollection errors)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.System.ComponentModel.Design.Serialization.IDesignerLoaderService.DependentLoadComplete(Boolean successful, ICollection errorCollection)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
at System.ComponentModel.Design.DesignerHost.BeginLoad(DesignerLoader loader)
I really need to see and modify design view of the control.
I would highly appreciate if anybody can advise how to solve this.
Thanks!
Seems like I was able to pinpoint the issue. It was one of the data source objects that was added drag and drop way. I opened the file ..Designer.cs and manually commented all lines with it. The design view started working again.
Thanks to everyone who was considering to assist.

Windows Form -- behavior of buttons?

First time I've used the windows form so I'm not very familiar with the interface. But how do I set behaviors when I add buttons? For example, if I want to click "Button 1" and have it open up a new window to enter information in different fields, how is this done?
Thank you.
edit: Sorry, I forgot to include the language. It's in C#, and I'm using MS Visual Studios. I've never really programed in C#.
Another question that just popped up: could I do this Windows Form in other languages such as C++?
Yes the comment above is key but, if your are using the UI designer on a windows form then under the properties tab on the side of visueal studios, you can view 'events'. from here double click the event you want, probably 'onclick'. This will create a method stub with the event handler automatically set up.
Look something like:
public void Button1_OnClick(Object sender, EventArgs e){
// open the other window for input
Form whateverForm = new Form();
whateverForm.show();
}
Hope this helps. Sorry im not sure about any c++
[Edit]
tutorial not great but take a look:
http://www.ehow.com/how_7241167_tutorial-microsoft-visual-studio.html

Where should I attach solution or project events in my Visual Studio add-in?

Can anyone suggest the best place to add solution or project events, such as ProjectAdded, to a Visual Studio add-in?
If I do this when the add-in connects then there's no solution loaded, so how can I tell when a solution has been loaded?
For example, if I write an event to handle project items being added, where should I attach this? The event would be fired by the project, and that in turn by the solution, so I can't attach the events when the add-in connects because there is no solution when the add-in connects.
On the other hand, if I add them in the Exec() event then I need to do checks such as whether the event has been attached already, and I'm sure there must be a neater way sometime between the connection events and the Exec() event.
You probably figured this out long ago, but anyway: You can setup your events from within OnConnection like shown below, this is a snippet of an Addin's Connect class (assuming you're using c#):
using System;
using System.Globalization;
using System.Reflection;
using System.Resources;
using EnvDTE;
using EnvDTE80;
using Extensibility;
using Microsoft.VisualStudio.CommandBars;
namespace MyAddin1
{
/// <summary>The object for implementing an Add-in.</summary>
/// <seealso class='IDTExtensibility2' />
public class Connect : IDTExtensibility2, IDTCommandTarget
{
private DTE2 _applicationObject;
private AddIn _addInInstance;
private SolutionEvents _solutionEvents;
public void OnConnection(object application, ext_ConnectMode connectMode,
object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
// check the value of connectMode here, depending on your scenario
if(connectMode == ...)
SetupEvents();
}
private void SetupEvents()
{
// this is important ...
_solutionEvents = _applicationObject.Events.SolutionEvents;
// wire up the events you need
_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(_solutionEvents_Opened);
_solutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(_solutionEvents_AfterClosing);
_solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(_solutionEvents_ProjectAdded);
}
// add procedures to handle the events here, plus any other
// handling you need, ie. OnDisconnection and friends
}
The main point is, to wire up the solution and project events you need, it's not important if a solution or project is already loaded. They're not attached to any particular solution or project, they're provided by the Visual Studio object model and are embedded within the EnvDTE namespace.
It wouldn't make much sense to do anything else anyway, since you can configure an addin to load when VS starts, and in this case there will never ever be any solutions/projects loaded.
There's a few catches though:
It's important that you keep a reference to the SolutionEvents class as a member variable within your connect class, otherwise the events will never fire, (see also here).
You need to make sure you check the connectMode parameter passed into OnConnection. This gets called multiple times with different parameters, and if you do it the wrong way you may get the event wired up multiple times, which definetly will be a problem. Also, usually any Addin IDE, like Menus and stuff, is set up from within OnConnection, so you may end up with duplicate menu items if you don't do it right.
Here's a few pointers, some of the code provided is VB code, in case you're looking for that:
HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an add-in
HOWTO: Getting Project and ProjectItem events from a Visual Studio .NET add-in.
HOWTO: Add an event handler from a Visual Studio add-in
Finally, here's a list of articles, about 70% of them cover basic and advanced topics regarding addins:
Resources about Visual Studio .NET extensibility
Find the section entitled MZ-Tools Articles Series (about add-ins) and have a look at what's covered there.

Resources