|
A macro to protect a code section with a Try...Catch block
|
Total Hit (3069) |
When you're working with the Visual Studio .NET code editor, typing a Try keyword plus the Enter key automatically creates the End Try statement. The following simple macro does something more interesting: it lets you select a portion of code and protect it with a Try...Catch...Finally...End Try blo
....Read More |
Rating
|
|
|
Adding external commands to VS.NET's Tools menu
|
Total Hit (2778) |
The VS.NET's Tools menu can be customized with your own commands, to launch external programs. For example, you may want to have a command that opens the current project's folder in a Windows Explorer window, to easily manage the project's files. To add such a new command, click Tools | External Too
....Read More |
Rating
|
|
|
Changing the project's output type
|
Total Hit (3292) |
When you start developing an application, the first thing you do in VS.NET is creating a new project and selecting its type: Windows Forms application, Class Library etc. However, it may happen that later in the development you want to change the project's output type. For example, you could have de
....Read More |
Rating
|
|
|
Creating a project into an existing folder
|
Total Hit (2638) |
When you create a new project, VS.NET automatically creates a folder with the project's name under the selected directory. If you name your project MyTestProject, and select an existing folder named c:\My Project\MyTestProject as destination directory, in reality the final project's folder will be c
....Read More |
Rating
|
|
|
|
Creating applications that target .NET Framework v. 1.0 and/or 1.1
|
Total Hit (2742) |
As explained in this article, the applications you create with one version of the framework, can target only that version or both, according to the settings you put in the appname.config file. (Where appname is the full name of your executable file including the extension, such as myapp.exe, so the
....Read More |
Rating
|
|
|
Creating custom help filters
|
Total Hit (2801) |
If you open the VS.NET documentation (either from within the IDE or by clicking the respective icon under the Start | Programs| Microsoft Visual Studio 2003 folder) you can use the Filtered by dropdown box to select a filter, and load in the list/tree control below only the subset of topics you're i
....Read More |
Rating
|
|
|
Exception debugging in Visual Studio .NET
|
Total Hit (2645) |
The Visual Studio debugger offers complete control on what happens when an application throws an exception, or calls a .NET method that throws an exception. You set all the relevant options from inside the Exceptions dialog box, which you bring up with the Debug | Exceptions menu command. This dialo
....Read More |
Rating
|
|
|
Exception debugging in Visual Studio .NET
|
Total Hit (3195) |
The Visual Studio debugger offers complete control on what happens when an application throws an exception, or calls a .NET method that throws an exception. You set all the relevant options from inside the Exceptions dialog box, which you bring up with the Debug | Exceptions menu command. This dialo
....Read More |
Rating
|
|
|
Including/excluding files in Visual Studio .NET
|
Total Hit (2628) |
Say that that you have an existing Visual Studio .NET project, and that you copy a lot of new source code files, images and other stuff from another project (maybe you're merging two projects, or a colleague wrote and passed those files to you). One approach to include the new files is to use the Pr
....Read More |
Rating
|
|
|
Linking a file in Visual Studio .NET
|
Total Hit (2715) |
If in VS.NET you add to the current project an existing file that's located outside the current project's directory, the file is first copied in the project's directory, and then it's added to the project. However, you may want to share the same source file among multiple projects, so that if you mo
....Read More |
Rating
|
|
|
Marking strings with a different color in source code documents
|
Total Hit (2601) |
When you build strings by concatenating hardcoded constant strings and variable strings, it's easy to forget a closing double quote, and thus receive a compile time error when you launch or compile the program (actually, you see that there is a syntax error even before, because the statement gets un
....Read More |
Rating
|
|
|
Quickly swap assignment operands
|
Total Hit (2765) |
It often happens that you need to swap the operands of an assignment. For example, say that you have this set of assignments:
«Code LangId=2»
p1.FirstName = m_FirstName
p1.LastName = m_LastName
«/Code»
and later in your source code you want to add a similar set of assignments, but with rever
....Read More |
Rating
|
|
|
Running ILDASM from inside Visual Studio .NET
|
Total Hit (3163) |
Nothing beats ILDASM when it's time to understand what your VB.NET or C# compiler actually emits. In this case you should prepare a desktop shortcut to ILDASM so that you can run it quickly, and then open a Windows Explorer window on the Bin directory of your project, so that you can easily drag you
....Read More |
Rating
|
|
|
Setting up multiple start-up projects
|
Total Hit (2524) |
By default, a solution has a single start-up project, namely the project that is automatically launched when you click Debug | Start or press F5. However, you have the option to start multiple projects of the solution when you call Start, something that is very useful to automatically start, in debu
....Read More |
Rating
|
|
|
Settings pre and post-build actions in VS.NET 2003
|
Total Hit (2626) |
VS.NET 2003 comes with a nice feature that allows you to automatically run an external executable file before or after a build. For example, you may want that after a build a Windows Explorer window is automatically opened on the output folder, so that you can easily run the compiled program. Or you
....Read More |
Rating
|
|
|
Shortcuts to useful VS.NET's commands
|
Total Hit (2714) |
Visual Studio .NET has a number of useful features that are often underused by developers, because they are hidden under several menus and not easily accessible. Here is a list of keyboard shortcuts to some of these commands:
Ctrl + - : moves the caret to its previous position.
Ctrl + Shift +
....Read More |
Rating
|
|
|
|
Transform a variable into a Property
|
Total Hit (2683) |
Thanks to Visual Studio.NET macros, it is quite simple to automate the task of transforming a Public field into a Property with the same name that accesses a private field of the same type.
Press Alt-F11 (or invoke the Macro IDE from the Tools|Macros submenu, select one macro module in the left-m
....Read More |
Rating
|
|
|
Understanding VS.NET public and private assemblies
|
Total Hit (2934) |
As you might have noticed, the Add Reference dialog in Visual Studio displays all the assemblies in the GAC, which brings up the following question: is there a way to have this list display assemblies that aren't in the GAC? The answer is yes, and the technique couldn't be easier.
Use the REGEDIT
....Read More |
Rating
|
|
|
Visually browsing hierarchical files
|
Total Hit (2741) |
VS.NET has a nice feature that allows you to visually navigate through the content of hierarchical files, and quickly jump to a particular section. Hierarchical files are all those files written in XML-like syntax, such as .HTML, .ASPX and .Config files. To use this feature, click the View | Other W
....Read More |
Rating
|
|
|
Add an horizontal scrollbar to a ListBox control
|
Total Hit (4817) |
By default, VB ListBox controls don't display an horizontal scrollbar, so if the items you add to the controls are wider than the control's Width, the end user isn't able to read them in their entirety.
Adding an horizontal scrollbar to a ListBox control is easy, however. You only have to increas
....Read More |
Rating
|
|
|
Add size grips to a form
|
Total Hit (2847) |
There are two simple ways to add the so-called size-grips to the bottom-right corner of a form. The first method is to add a StatusBar control, which includes a size-grip of its own. The second method is to add a multiline TextBox control, set its ScrollBars property to 3-Both and add some resizing
....Read More |
Rating
|
|
|
Append a string to a textbox quickly and without flickering
|
Total Hit (2948) |
The usual way to append text to a TextBox or a RichTextBox control is to concatenate the current contents with the new string:
«Code LangId=1»
Text1.Text = Text1.Text & newString
«/Code»
Here is a different approach, which is slightly faster and causes less flickering: «Code LangId=1»
Text1
....Read More |
Rating
|
|
|
Avoid beeps on forms without a default button
|
Total Hit (4031) |
If a form contains one CommandButton control whose Default property is set to True, the Enter key activates the CommandButton. If the form doesn't contain any default CommandButton control, however, pressing the Enter key when the focus is inside a TextBox control (and a few other controls as well)
....Read More |
Rating
|
|
|
Multiple compilation constants
|
Total Hit (2283) |
Visual Basic's documentation does not explain how to specify more than just one conditional compilation constant in the Advanced tab of the Options dialog. The correct way is using a colon as a delimiter, as in:
demo = -1: version = 100
Note that you can only assign integer numeric values, an
....Read More |
Rating
|
|
|
Quick Property Edits
|
Total Hit (2214) |
When you are placing controls on a form at design time and wish to edit one of its properties, the quickest way to switch to the Property window is pressing the Ctrl+Shift+key combination, where key is the first letter in the property name. For instance, to quickly modify the Caption property you si
....Read More |
Rating
|
|
|
Quickly copy field attributes when creating tables
|
Total Hit (3051) |
Under VB6 you can create new SQL Server and Oracle tables - but not MDB tables - without leaving the environment. You only have open the DataView window, right-click on the Tables folder of a database, and select the New Table mennu command.
When working with similar tables, that is tables with m
....Read More |
Rating
|
|
|
Start the IDE with maximized code and form windows
|
Total Hit (2271) |
The VB IDE remembers most of the configuration settings that were active when you closed the previous session. However, the maximized status of child MDI windows (the code editor and the designer window) isn't remembered, and the IDE always starts with non-maximized windows. To have VB always start
....Read More |
Rating
|
|
|
A macro to protect a code section with a Try...Catch block
|
Total Hit (3090) |
When you're working with the Visual Studio .NET code editor, typing a Try keyword plus the Enter key automatically creates the End Try statement. The following simple macro does something more interesting: it lets you select a portion of code and protect it with a Try...Catch...Finally...End Try blo
....Read More |
Rating
|
|