I am just learning C# programming and I had been using Microsoft Visual 2010 express.
I loaded Visual Studio express 2012 for Windows desktop. Everything went well with the install and I started to practice some coding, and that is when I ran into an issue.
I needed to define some variables outside of the form so that they would not be restricted to a single form.
In 2010 I would place them in .cs file after the following lines:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
However in 2012 I don't have that option the as it looks like this:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
The " InitializeComponent();" is no where to be found.
If I load a project I had written in 2010 into 2012 the "InitializeComponent();" is there and 2012 has no complaints about it.
I have tried defining public variables, etc. in different places in 2012 but with no luck.
Any suggestions would be appreciated.
Thanks in advance
Nick
Open the Solution Explorer window, click on the arrow to expand the Form1.vb and the on the arrow to expand the Form1 class. You will see the missing InitializeComponent method
Alternatively you could click the button on the Solution Explorer window that has the Tooltip Show All Files and you will see the Form1.Designer.vb file if you exapnd again the main Form1.vb node.
Related
Is there a way to create custom shorthand's in Visual Studio 2017.
Just like ctor or prop?
I would like to create a shorthand for unit-tests, to just type in for instance test and then having a predefined function to edit like:
public void Method_Condition_Expected()
{
// Arrange
// Act
// Assert
}
As #Peter B has suggested for Visual Studio itself you can do it with Snippet Designer (Tools->Code Snippets Manager).
I found out right now, that my installed Tool ReSharper (2016.3) has an option to create so-called Live-Template's.
With that, I can create a Template like this:
public void $Method$_$Condition$_$Expected$()
{
// Arrange
// Act
// Assert
}
The nice part is now, that i can tab through Method,Condition and Expected and overwrite the values.
How to use: Mark a Code-Area such like the code Above in Visual Studio then click on Resharper->Tools->Create Live Template from Selection->Create and Edit.
Now wrap code-areas for tabing through with $ for instance like $Method$ and give a shortcut name such like test.
I hope this helps somebody else as well.
For a closer Comparision between Visual Studio Snippet Manager and Resharper Live Templates see Difference between Live Template and Visual Studio Snippet
Visual Studio 2012 crashes when open a form that contains a Visio 2013 Preview Drawing control. (Microsoft Visio 15.0 Drawing Control - Com Component).
Steps to reproduce this issue.
Open Visual Studio 2012
Create a new Windows Forms Application (C#)
Add COM Component Microsoft Visio 15.0 Drawing control to toolbox.
Place Visio Drawing Control on Form2.cs[Design].
Save all files, project and solution.
Close Form1.cs [Design] in the Visual Studio 2012 IDE.
Double click Form1.cs in the Solution explorer to edit form [Design] view.
Visual Studio Application Crashes at this point.
Is this a known bug in Visio 2013 Preview.
Using the Visio 2013 Drawing Control in VB6 applications also produces a similar result with &H80004005 (-2147467259) error message shown.
Our product makes use of the Visio 2013 control in a VB6 application. It is also an issue in Visual Studio 2012.
Any ideas of what is going on?
This is indeed a known bug: See http://connect.microsoft.com/VisualStudio/feedback/details/766229/visio-2013-preview-drawing-control-on-a-windows-forms-application-crashes
The best workaround I could come up with so far was to instantiate the drawing control in code only. In other words. Don't drag it onto your form (etc.) from the toolbox in the IDE but only create and instantiate the control from within the code. That way the control does not appear in the GUI form editor and it will not freeze your Visual Studio instance.
If you are not sure how to do that you can always drag it temporarily to your form and lift the relevant code for the control from your FormName.Designer.cs (or .vb) file.
Mind you my experience is with VS2012 only. I am not sure if you can even use the control in VB6 (don't have it installed to test).
Option Explicit
Private WithEvents moo As Visocxctl.DrawingControl
Private Sub Command1_Click()
Set moo = Form1.Controls.Add("VisOcx.DrawingControl.1", "VisioRuntime")
moo.Left = 0
moo.Top = 0
moo.Visible = True
End Sub
Try this workaround:
Visio Drawing Control Fails in Visual Studio 2012.
Replace Office14 with Office15 for Visio 2013. I could successfully drop the control in design-time and run a sample windows form application. This is a known bug in VS2012 when working with any version of Visio drawing control.
I have currently written a sub, written in VBA, that is called by the click of a button on an excel document. The sub takes data in the cells of the document and sends them to a web service.
All of this works flawlessly when Visual Studio automates Excel.
I am wondering if there is a way to save this excel file to where it does not need Visual Studio to run. I want to be able to distribute the excel file to other people so they can use the web service with there own data.
Is this possible... If so how?
Thanks Alot!
Excel has a Visual Basic IDE built into it. You can press Alt-F11 to get to it or go to Tools -> Macro -> Visual Basic Editor. You can edit/add/write code here that will travel with the sheet you're working on.
To accomplish what you're looking to do, create a button in the spreadsheet. You can use the Visual Basic toolbox, which is accessed by View -> Toolbars -> Visual Basic. Create the button. If you double click that button while in design mode, the VB editor will be launched and it will take you to the code for that button. Paste the code you wrote into there and you'll be set. Your sub should look something like this:
Private Sub CommandButton1_Click()
' Code goes here
End Sub
I'm working with Visual studio 2008.
I have a form inherited from DockContent class (Weifen Luo dock panel suite if you ever heard about that library).
I can add another controls on that form. But when I tried to add an event handler via Property tab, Visual studio generated an exception "type is not marked as serializable".
What should I do to fix that problem ?
I'm guessing the class you are working with has the [Serializable] attribute. Because events are non-serializable, you will have to mark them this way.
[field:NonSerialized]
private EventHandler myEvent;
So i am working on a wpf browser project in c# but on of the class library's I need is in vb.net. So in VS2010 I have imported the solution called vblib and it shows up on the solution explorer. The class i need is public class vbintopm. So right now I have
using vblib;
//down a few lines
vbintopm callvb= new vbintopm;
>
now I keep getting errors that VS can't find class even though its in the solution explorer. What do i need to fix to this?
You need to actually reference the library from your C# project. Right-click the project and then select "Add Reference". On the "Projects" tab, select the project and click "OK".