Switch On The Code RSS Button - Click to Subscribe
Oct
2

WPF Tutorial - Getting the DoubleClick Event

In WinForms, everything that derived from System.Windows.Forms.Control had the MouseDoubleClick event - and not suprisingly, in WPF, everything derived from System.Windows.Controls.Control also has a MouseDoubleClick event. But there is a key difference - in WinForms, almost everything that gets displayed on the screen is derived from System.Windows.Forms.Control in some way - while in WPF, there are a number of items you can put on the screen that do not actually derive from System.Windows.Controls.Control. So today we are going to take a look at how to get double clicks when you are not derived from System.Windows.Controls.Control.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | No Comments »

Oct
1

Creating Your First AutoHotkey Script

Working and living as a programmer means I am pretty much on my computer or playing around on it all the time - sometimes maybe too much. I am sure many of you out there can relate. This also means I am always looking for tools to make my life easier. As of late I have found AutoHotkey to be a really cool time saving application. Well today I am going to show you how to create an AutoHotkey script that will help reduce redundant work.

 
Read More »

Posted in AutoHotkey, All Tutorials | No Comments »

Sep
29

Dynamic Classes in Flex and Actionscript

I have known about dynamic classes in Flex and Actionscript for a while but I just recently started playing around with them. Basically they are declared classes that can have additional properties tacked on to them at runtime. To add this ability to a class you simply need to add the keyword dynamic to the class definition. So below we have very simple dynamic class.

 
Read More »

Posted in Flex, All Tutorials | 1 Comment »

Sep
26

C++ Tutorial - Sorting STL Containers

Welcome to the first C++ tutorial ever written for Switch On The Code. Our tutorials are typically centered around C# and Flex, however lots of people in the world (including me) program in C++ every day - and the standard template library is an integral part of any modern C++ project. This tutorial is going to demonstrate how to use the built-in algorithms to perform custom sorting on standard template library collections.
 
Read More »

Posted in C++, All Tutorials | No Comments »

Sep
25

WPF Tutorial - Using The Built-In Commands

One of the features that WPF has is actually a blast from the past - something that MFC used to have, but was never included in WinForms. This is the concept of Commands. Commands are somewhat like events in that they are based on actions in the user interface, a command can [...]
 
Read More »

Posted in WPF, XAML, All Tutorials | No Comments »

Sep
24

Adding Dynamic Rows To Flex DataGrid

One of the many things people want to do when using a DataGrid is adding new rows to the data. Now this can be done a bunch of different ways. One method is using a popup to handle adding items to the collection the grid is bound to. Another method is to add another row directly into the grid. This tutorial is going to focus on the second of the above methods.
 
Read More »

Posted in Flex, All Tutorials | 2 Comments »

Sep
23

C# Snippet Tutorial - The ?? Operator

Just the other day I came across a C# operator that I found particularly useful and decided to share it with everyone here at SOTC - the ?? operator. The briefest explanation is this: ?? is used a lot like a conditional (:?), except it will return the thing on the left if it's not null, or else it will return the thing on the right.
 
Read More »

Posted in C#, All Tutorials | No Comments »

Sep
19

Zune Game Development - Getting Started

Remember that Game Studio software Microsoft released a while ago that let anyone develop games for the XBox 360? Believe it or not, they just released 3.0 beta that lets anyone write games for the Zune as well! This tutorial is going go through all of the software needed and then demonstrate how to create a simple 'Hello World' application that will run on your Zune device.
 
Read More »

Posted in Zune, XNA, All Tutorials | 5 Comments »

Sep
16

WPF Tutorial - Using An ItemsPanel

One of the most useful things about WPF is how flexible all of the built in controls are. Don't like how the tabs look on a tab control? Restyle them! Need to have images inside your combo box? Sure, no problem! This flexibility extends deep into a number of controls, and today we are going to take a look at controlling layout in an ItemsControl by setting the ItemsPanel.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | No Comments »

Sep
11

Flex DataGrid Selected Row Styling

So in my previous tutorial I had an example on how to change a selected row's styling. At the end of that article I said there is a better way to do this, well today I am going to show that better method. This tutorial is going to to show a good method for changing just about anything on a selected row in any list based component.

 
Read More »

Posted in Flex, All Tutorials | No Comments »

Sep
10

How Google Chrome Stores Passwords

Every browser released in the last decade has some sort of password management system, and Google Chrome is no different. I've been sifting through the Chrome source code, released under the open source project Chromium, and I've found out how they do it. In this tutorial, I'll post all of the source code used by Google Chrome to quickly and securely save your passwords.
 
Read More »

Posted in Google Chrome, All Tutorials | 32 Comments »

Sep
9

C# Dialogs, Part 2 - Custom Dialogs

Ok, so in Part 1 we went over the MessageBox that C# offers. As simple and easy as it is to use MessageBox, sometimes you need something more customized to your needs. Although MessageBox is extremely simple to use, it is almost as easy to create your very own dialog and use whatever you want.
 
Read More »

Posted in C#, All Tutorials | 2 Comments »

Sep
4

10 Things To Like About Google Chrome

What kind of semi web developer blog would we be without posting a review of Google's new browser, Chrome? I don't know, but we're not writing one. Instead, we've spent the last two days immersing ourselves in Google Chrome to bring you the top 10 things that might just make Chrome worth a glance.
 
Read More »

Posted in Google Chrome, Tech News | 11 Comments »

Sep
3

WPF Tutorial - Priority Bindings

Bindings, bindings, bindings. WPF is all about bindings - and you can't be all about bindings unless there are a whole bunch of different types to play with. We have looked at a couple different types here at SOTC before - I won't list them all, it is probably just easier to look at list in the WPF category. Today we are going to introduce yet another type of binding - the Priority Binding.
 
Read More »

Posted in WPF, All Tutorials | 1 Comment »

Sep
2

Accessing DataGrid ItemRenderers

In order to do a lot of crazy things with the Flex DataGrid you may need to access the item renderers. Today I am going to show a quick and easy way to get to the array of item renderers for the entire DataGrid or any list based component. Now recently I got a comment asking about how to change a certain font style of the selected row. There are a couple ways to achieve this. I am going to show how to do this using the item renderer array. This tutorial is about how to get to that entire item renderer list.

 
Read More »

Posted in Flex, All Tutorials | No Comments »

Aug
28

C# Tutorial - Object Finalizers

Recently, in a tutorial about Weak References in C#, we talked a bit about garbage collection and how the garbage collector works in .NET. I figured since we already started addressing that stuff, there is no reason not to delve deeper. And so, today we are going to take a look at how object finalizers work in C#.
 
Read More »

Posted in C#, All Tutorials | 2 Comments »

Aug
27

C# Dialogs, Part 1 - MessageBox

We have all seen them, and most of the time they mark something bad. They are dialog boxes and not only have they been the bane of all computer users since the GUI was invented, but they are really a key to any software project. Whether you are making a simple text editor, or you programming a time viewing machine, chances are you at some point going to need a dialog box. Luckily, with C# adding one is super easy.
 
Read More »

Posted in C#, All Tutorials | 1 Comment »

Aug
21

WPF Tutorial - Using Splash Screens in SP1

Splash screens - everyone loves them, right? Actually, I'm not a big fan of them, but sometimes they are a necessary evil - especially in the world of WPF. A cold start up of a WPF application can be, well, slow - mostly because there are a lot of common WPF dlls that need to be loaded. Once they are loaded for the first time after bootup, WPF apps generally start pretty fast, but that first WPF app after a reboot can crunch away at your hard drive for quite a few seconds.
 
Read More »

Posted in WPF, All Tutorials | 1 Comment »

Aug
20

XAML Tutorial - Changing Text Color on Mouse Over

I received a comment on an old Silverlight 1.1 post a while ago asking how to change the foreground of text when the user has moused over it. I could have pasted the solution as a reply in the comment, but I felt it deserved its very own tutorial.
 
Read More »

Posted in XAML, All Tutorials | No Comments »

Aug
15

Drupal 6 Basic Javascript w/ jQuery

Here at SOTC we have been working with Drupal as of late where we are working on updating our site. One of things that I couldn't find a whole lot of documentation on it is getting simple basic Javascript stuff working in Drupal 6. So to get people moving in the correct direction I decided to throw out a small tutorial on this, especially since Drupal 6 has built in support for jQuery, a Javascript library - which should make adding fancy stuff pretty easy.
 
Read More »

Posted in Drupal, Javascript, All Tutorials | No Comments »

Aug
13

C# Tutorial - Weak References

We all know (hopefully) that C# is a garbage-collected language. In general, what this means is that we as programmers don't need to free our own memory - the garbage collector will free that memory for us once it is no longer being referenced. Now, of course, garbage collection is a lot more complicated than that, and writing a good garbage collector is actually a relatively hard problem. And the fact that writing a perfect garbage collector is probably impossible is the reason why things like C#'s Weak Reference object exist.
 
Read More »

Posted in C#, All Tutorials | 2 Comments »

Aug
7

Simple DataGrid Item Editor in Flex

One of the more mysterious features of the Flex DataGrid is how to use item editors. Well I am going to start a few tutorials on this subject. This first tutorial is going to jump in and show how to create an easy to use item editor. Item editors can be simple or very complex - anything from a text input to a full input form. This tutorial is going to use a basic ComboBox to change a single value.

 
Read More »

Posted in Flex, All Tutorials | 1 Comment »

Aug
6

C# Tutorial - Switch Statement Games

Today, we are going to take a look at Switch on the Code's namesake - the switch statement. More specifically, we are going to take a look at some of the lesser known behaviors of the switch statement in C#, hopefully giving you some new syntactic sugar to use in the process.
 
Read More »

Posted in C#, All Tutorials | 4 Comments »

Aug
4

Javascript Tutorial - Inline Sliding Panels

We've written several different tutorials about sliding panels, and each time we get requests for different features and functionality. The first feature I addressed was starting the panels in an up position and having them slide down. Lately we've been getting comments about how to put the panels inline with the rest of the content. That is, when the panel expands or contracts, the rest of the page moves with them. That's what this tutorial will address today.
 
Read More »

Posted in Javascript, All Tutorials | 6 Comments »

Jul
30

Flex DataGrid Goodies - Row Color and Others

In Flex one of the most used and useful components is the DataGrid, and it happens to be the component we get the most questions on. This tutorial's sole purpose is to show off some of the cool things that can be done with the Flex Datagrid and to answer a few of the questions that we have outstanding. Some of the topics covered in this tutorial include changing the row color, header colors, header renderers, using dynamic xml data and others.

 
Read More »

Posted in Flex, All Tutorials | 24 Comments »

Jul
29

The C# Preprocessor - An Overview

Did you know that C# actually does have a preprocessor? Probably the most common C# preprocessor directive that you see is the #region directive, and that doesn't even have any impact on the code. Now the preprocessor for C# is nowhere near as powerful as the ones for C and C++ (for instance, no macros), but it does let you do a couple of handy things.
 
Read More »

Posted in C#, All Tutorials | 4 Comments »

Jul
28

C# Snippet Tutorial - Comparing IP Addresses

Comparing two IP Addresses is something that has caused me frustration on more than one occasion. Simply put, I always assume the default == operator will tell me if the addresses contained in the objects are equal, and as always, it does not.
 
Read More »

Posted in Snippet Tutorials, C#, All Tutorials | No Comments »

Jul
25

C# Snippet Tutorial - The Web Browser Control

Ok, so you may be thinking to yourself "Why do I need a browser control when I have Firefox or IE?". Well, considering it has all the power of Internet Explorer, you can use it for lots of things. You can use it to show a website in your application or even just load in an HTML file from the local computer. The greatest thing is that it is quite easy to use and control.
 
Read More »

Posted in Snippet Tutorials, C#, All Tutorials | No Comments »

Jul
22

WPF Snippet Tutorial - Aligning ListView Items

WPF is powerful. So powerful in fact, that sometimes it's hard to find styles and settings to make it do what you want. Aligning ListView items was one such example for me. This snippet tutorial will show you how to use a style to vertically and horizontally align the contents of ListView cells.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | 3 Comments »

Jul
21

WPF Tutorial - Using MultiBindings

If you've touched WPF at all, you've probably realized that bindings are an extremely important piece of the framework. We've talked about WPF bindings a number of times here at Switch On The Code (most recently in a post where we talked about Binding Converters) - and yet we have just barely scratched the surface of the world of bindings. Today, we are going to take a look at MultiBindings.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | No Comments »

Jul
17

Simple Flex Drag and Drop

Today I am going to run through a smallish tutorial on creating and using drag and drop in Flex using the DragManager class, which is a utility provided to make drag and drop easy. I should also mention, right off the bat, that some things like lists already have various drag and drop features built in. I however will be showing a example that is useful for any custom drag jobs you might need to do.

 
Read More »

Posted in Flex, All Tutorials | 1 Comment »

Jul
16

WPF Tutorial - How To Use A DataTemplateSelector

DataTemplates are an extremely powerful part of WPF, and by using them, you can abstract all sorts of display code. However, there are times when they fall short - and initially when I was learning WPF I was disappointed by that. For instance, you only get to set one DataTemplate on an items control, and while that made sense, it felt limiting. What if I wanted to use different templates depending on the content of the item? Do I have to build all that logic into a single data template?
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | 1 Comment »

Jul
15

WPF Tutorial - Binding Converters

I'm going to come right out and say it, binding converters are one of the nicest pieces of WPF I've run across so far. Simply put, they provide a translation between your binding source and destination. The most common use I've found is when I'm binding to user interface elements, because on many occasions I don't store something in a data member that can just be stuck on the screen. This tutorial will provide an introduction to what binding converters are and how to use them.
 
Read More »

Posted in WPF, C#, All Tutorials | 1 Comment »

Jul
14

Signing up for Slicehost

I'm starting work on a new website, and I'm downright tired of my old hosting company. Their tools are cumbersome, their plans are undecipherable, and the level of spam email I get from them is reaching impressive levels. I've watched as a variety of people, including the SOTC guys (Red, Tall, and "Fat") have migrated from shared hosting, to dedicated hosting, to even larger dedicated hosting, and it just looks like a miserable high-effort experience to me.
 
Read More »

Posted in Neat Websites, All Tutorials | 4 Comments »

Jul
10

How To Configure And Use Visual Studio Macros

Microsoft Visual Studio has pretty much every operation you'd ever need right at your fingertips through the built in keystrokes. However, there are times when you'd like the text editor to do something that isn't built in. This is where macros come in. Macros can be wired up to keystrokes and can do pretty much unlimited modifications to your text - as long as you're willing to program it. In this tutorial, I'm going to demonstrate how to import an existing macro and configure a keystroke for it.
 
Read More »

Posted in Visual Studio, All Tutorials | No Comments »

Jul
9

C# Tutorial - Using The Built In OLEDB CSV Parser

So, a while ago, one of the other writers here wrote a small tutorial on parsing simple CSV files in C#. It mostly just showed off the string split method, and only worked on really simple CSV files - no quoted fields, etc. Well, we got a comment asking about that, so today I sat down thinking I would write up a more robust parser. But as I read through the RFC that describes CSV files, I thought to myself, am I suffering from NIH (not invented here) syndrome? Do I really need to write a full CSV parser?
 
Read More »

Posted in C#, All Tutorials | 13 Comments »

Jul
2

Using a PHP Proxy with Flex to talk Cross Domain

Now one of the worst pieces of working with Flex is cross domain security, oh how I hate it sometimes. Now I understand that there is a reason that the Flash player can't just grab information from any domain it wants all willy nilly, but sometimes this really hampers getting something built. Silverlight also has this issue, and recently I went over using Yahoo Pipes for a proxy for a Silverlight Twitter Client. Today I am going to show how to build a simple PHP script to use as a cross domain proxy.
 
Read More »

Posted in PHP, Flex, All Tutorials | 2 Comments »

Jul
1

C# Tutorial - Method Attributes And Reflection

Today we are going to take a look at a deep and yet often underused part of C# - method attributes. First we are going to go through what they are and take a look at the built in attributes, and look at how to poke at them through reflection (which we have taken a quick look at before, in Some Notes On Invoking). By the end of the tutorial, through, we will be making our own custom attributes - and we will be using those attributes to make our code more dynamic and extensible.
 
Read More »

Posted in C#, All Tutorials | 3 Comments »

Jun
25

Working With The WPF Dispatcher

Proper use of threads can greatly increase the responsiveness of your WPF applications. Unfortunately, you can't update any UI controls from a thread that doesn't own the control. In .NET 2.0, you used Control.Invoke(). Now, we've got something similar but more powerful - the Dispatcher. This tutorial will explain what the Dispatcher is and how to use it.
 
Read More »

Posted in WPF, C#, All Tutorials | 3 Comments »

Jun
24

WPF Tutorial - Using WPF In WinForms

A little while back, we did a tutorial on how to embed WinFoms controls inside of WPF application (you can read all about it here). Today, we are going to flip that on its head - we are going to take a look at how to embed WPF controls inside of a WinForms application.

 
Read More »

Posted in WPF, C#, All Tutorials | 5 Comments »

Jun
20

C# Tutorial - XML Serialization

A while ago we posted a tutorial on how to serialize objects to a binary file. While this is very useful, unfortunately the resulting file is not very human readable. In this tutorial, I'm going to demonstrate how to serialize your own objects to and from an XML file.
 
Read More »

Posted in C#, All Tutorials | 15 Comments »

Jun
19

Basic LINQ Syntax in PHP with PHPLinq

I am a big fan of LINQ (if you don't know what it is check out our Intro to LINQ Tutorial in C#) and I just started playing with an interesting php library, PHPLinq (created by Maarten Balliauw), for integrating a LINQ-like syntax into PHP. This tutorial is going to go over the basics of using this library and some of the cool things that can be done with it.
 
Read More »

Posted in PHP, All Tutorials | 3 Comments »

Jun
17

Javascript Tutorial - Radial Menus Part 1

Sometimes, user interfaces can be really constraining. A whole lot of stuff to do, and not nearly enough pixels to do it in. In regular desktop applications, in is extremely common to put useful and repetitive items in a context menu, to keep them from cluttering up the screen. However, it is generally frowned upon to put context menus on a web page - because then they will interfere with the browser's normal context menu. But, as always, there are special cases - for instance, Google Maps has its own context menu, and it seems to work pretty well.

 
Read More »

Posted in Javascript, All Tutorials | 2 Comments »

Jun
13

Javascript Tutorial - Getting User Input with Prompt and Confirm

There's lots of times when you might want to ask a user a simple yes or no question, or ask for some text input. In this tutorial, I'm going to demonstrate how to use the confirm and prompt functions in javascript to get feedback from your users.
 
Read More »

Posted in Javascript, All Tutorials | 5 Comments »

Jun
12

Adobe AIR and Flex - SQLConnection

Adobe added the ability to use local databases when they created AIR. This is one of the many features that help make Adobe AIR a great solution for cross platform desktop applications. In this quick tutorial I am going to show how to create a database file and open a connection to it. The code is very simple so let's jump right into it.

 
Read More »

Posted in Adobe AIR, Flex, All Tutorials | 3 Comments »

Jun
11

CSS Snippet Tutorial - Putting Images On Buttons

So, about those standard browser form buttons - kind of boring, aren't they? All grey and flat (although if your lucky, your browser might even give you some gradients). You know the ones I'm talking about - the buttons that you get by writing html like . And while that produces a perfectly functional button, wheres the spice? Wheres the pizazz!?

 
Read More »

Posted in CSS, All Tutorials | No Comments »

Jun
6

Silverlight 2 and Twitter - A Simple Example

It might be a surprise to see me (The Fattest) writing about Silverlight, but I have had some fun playing around with it recently. So I decided I would write up a quick tutorial on how to build a Silverlight widget that shows the last five tweets (messages) from twitter. Now be forewarned I am not a C# expert, two other people at SOTC are, nor am I a Silverlight expert. I do however really enjoy playing around on twitter (The Fattest's Twitter Account) and with RIAs so I think I am qualified enough. :)

 
Read More »

Posted in Silverlight, C#, All Tutorials | 1 Comment »

Jun
4

Simple AJAX - PHP and Javascript

So, we now have a pretty common appearance of Web 2.0 across the world, but what exactly is Web 2.0? Really there are not set definitions or rules behind Web 2.0, it is just a way of describing a new set of technologies that have recreated the web. One of the more exciting and cool technologies is asynchronous server communication, sometimes referred as AJAX. With AJAX you don't need to refresh a page to get information from the server. You can call server pages and get the response, all with Javascript. In this tutorial I will show you the most basic way to get a response from a PHP script.
 
Read More »

Posted in PHP, Javascript, All Tutorials | 12 Comments »

Jun
3

Javascript Tutorial - Draggable View In A Container

There are all sorts of fun things that you can do in javascript and html once you have a basic drag infrastructure working - and in fact we have covered a whole bunch of these possibilities here at Switch on the Code. Today we are going to take a look at another one - using a container as a sort of 'window' on a larger object. Almost every mapping website makes use of this technique, and Google Maps probably does it best - you only have so much space on the screen to look at the map, but you can grab and drag around the map inside of its container to view different areas.

 
Read More »

Posted in Javascript, All Tutorials | 2 Comments »

May
29

Flex BrowserManager - Browser History and the Back Button Fun

So, how many times have you and I read something on the web that says you shouldn't use Flash/Flex because it breaks the back button? Well I for one say fooey to this. Today I am going to show you how to fix the back button in Flex 3 and add states to the browser history. Inside the Flex 3 framework there is a nice gem that can be used, it is a singleton (for more info check out our Singleton Tutorial) class called BrowserManager. This class allows us to change the url and receive notices when the user or browser changes the url.

 
Read More »

Posted in Flex, All Tutorials | 6 Comments »

May
28

Javascript Tutorial - Generic Resizeable Container

So a long while ago (last November), we posted some tutorials on how to create a resizeable textbox (Part 1, Part 2, and Part 3). We even did a post on how you could integrate the new textbox into Wordpress. Well, I got a request recently to expand the resizeable textbox code so that it could be a resizeable container for anything on a web page. So the result of that request is what we are going to be taking a look at today.

 
Read More »

Posted in Javascript, All Tutorials | 2 Comments »

May
23

Javascript Sliding Panels - Starting the Panels Up

I know we've done sliding panels in the past - in fact we've done it twice (here and here), but one comment that appeared a couple of times was the desire to start the panels in the up position. In this tutorial, I'm going to demonstrate how to create a simple sliding panel that starts in the up position and slides down when the user clicks a header above the panel.
 
Read More »

Posted in Javascript, All Tutorials | 8 Comments »

May
20

WPF Tutorial - Using WinForms In WPF

So we all know that WPF is awesome, but it is still a very young framework. And so, sometimes, it doesn't have everything that we might want or desire. For instance, there are a number of controls in WinForms that don't exist in WPF - and they come in handy once in a while. What we are going to look at today is how to use WinForms controls inside of WPF - a very easy and almost painless process, in my opinion.
 
Read More »

Posted in WPF, C#, All Tutorials | 1 Comment »

May
14

Javascript Tutorial - Continuous Pagination

Woah there, what's this! A Javascript tutorial!? Yes, I know its been a while since a Javascript tutorial graced the pages of Switch On The Code - but what can I say? I kind of got bored with writing them. And so, after a few month hiatus (and a couple fresh ideas for tutorials), they are back.
 
Read More »

Posted in Javascript, All Tutorials | 6 Comments »

May
13

C# Snippet Tutorial - Get File Listings

Ok, so can you even begin to tell me how many files you have on your computer? I can't either. There are so many reasons you could need to get file listings in C#, and thanks to the System.IO namespace, doing so is just about as easy as including the namespace itself. Really all you need to do is create a variable, then a loop.

 
Read More »

Posted in C#, All Tutorials | 2 Comments »

May
12

Getting Image Metadata with C#

Everyone has images. Maybe you're a photographer, a graphic artist, or you simply had a really awesome vacation, but chances are you have a lot of them. What you may or may not know is that every image contains extra information about itself: when it was taken or created, the size of the image, and sometimes even details such as the focal length and type of lens used. Almost every image has some sort of extra data, called metadata, and using C# we can write a function or even a class to help us get this metadata from the image.
 
Read More »

Posted in C#, All Tutorials | 1 Comment »

May
8

C# Snippet Tutorial - Dictionary Collections

So, we have all used arrays, and even sometimes a nice HashTable to get things sorted and organized. There are so many uses for an array, and even more for a nice HashTable. But, have you ever noticed that a HashTable is all objects? The Key in each Key/Value Pair is an Object, along with the value itself. But what happens if you don't need something so generic as an object? Well, you can get really specific and really crazy with a collection called Dictionary.
 
Read More »

Posted in Snippet Tutorials, C#, All Tutorials | 2 Comments »

May
7

Visual Studio - How To Create Item Templates

Visual Studio actually has a very powerful wizard and template system, which when used correctly, can automate large amounts of tedious work. Today we are going to take a look at how to create Item Templates for Visual Studio, which is actually extremely simple to do.
 
Read More »

Posted in Visual Studio, C#, All Tutorials | 1 Comment »

May
6

C# Snippet Tutorial - Custom List Sorting

The List is one of my favorite additions to the .NET framework. It has built-in mechanisms to perform efficient sorting and searching. In this snippet tutorial, I'm going to demonstrate how to customize the sorting routines used by the List class.
 
Read More »

Posted in C#, All Tutorials | 6 Comments »

May
2

C# Snippet Tutorial - Modify a Cell’s Selected Text

In this short tutorial, I'm going to show you how to change the text selection in a DataGridViewCell. There's lots of reasons why someone would want to do this, like if someone enters something incorrectly, maybe you want to select all the text so they can enter something else.
 
Read More »

Posted in C#, All Tutorials | 2 Comments »

May
1

Building Flex Degrafa Tic Tac Toe - Part 1

This is the first of a several part tutorial that is going to explain how the Tic Tac Toe application was built using Flex and Degrafa. If you haven't checked out the introduction to the game we are going to build check out the Introduction to Tic Tac Toe using Degrafa and Flex. In this first part I am going to go over how to do some basic drawing using Degrafa and creating the game grid.
 
Read More »

Posted in Flex, All Tutorials | 1 Comment »

Apr
29

C# Tutorial - Binding a DataGridView to a Collection

This tutorial is kind of a follow-up to my previous tutorial about binding a DataGridView to an Access database. In this tutorial, I'm going to demonstrate how to bind a DataGridView to a .NET collection.
 
Read More »

Posted in C#, All Tutorials | 11 Comments »

Apr
28

Taking Some Screenshots with C#

Here at Switch on the Code we do some pretty neat things with all sorts of code, and all this requires a ton of screenshots to help explain all the craziness. But besides having that good ol' fashion "Print Screen" button, we can actually use C# to take a screenshot for us. The best part of all is that it is only a couple lines of code. So lets just go ahead and dive right into it.
 
Read More »

Posted in C#, All Tutorials | 1 Comment »

Apr
25

WinForms Tutorial - Manage Your Own Double Buffering

Double buffering in WinForms, especially .NET 2.0 and up, is really nice. It gets rid of almost all flicker on your control, and all you have to do to turn it on is flip a simple property (you set the property DoubleBuffered to true. However, by making it so easy, .NET took away a lot of control over the double buffering process - and so in a select few instances, it is better to manage the double buffering of your control yourself. Today, I am going to walk through how to do that.
 
Read More »

Posted in C#, All Tutorials | 6 Comments »

Apr
23

Flex Custom Cursor Tutorial

On our site here we are kinda obsessed with showing how to use your own cursors in everything - and so now its time for a tutorial on how to do the basic cursor manipulation in flex. In this tutorial you will learn how to replace the cursor with your own custom image. There are some more complex techniques that can be used for cursor management in Flex but I am going to hold these off for a later tutorial, as most people probably won't need them.
 
Read More »

Posted in Flex, All Tutorials | 7 Comments »

Apr
22

C# Snippet Tutorial - Using StringBuilder

Everyone loves strings, you use them all the time in writing code (especially if you are writing any code that needs to interact with the user). And C# makes it really easy to work with strings - the useful operators just work (like '+' and '+=') and every object has the extremely useful ToString function call. In fact, strings are so easy to work with in C#, one might almost say that they are too easy to work with.
 
Read More »

Posted in C#, All Tutorials | 5 Comments »

Apr
17

Building a Simple CSV Parser in C#

So you are sitting around and you somehow have 100 Comma Separated Value files (CSV) and you are not quite sure exactly what the best way to read them is. Well, if you are using Visual Studio and C#, you are in quite a bit of luck, because you can read a CSV file quite easily. With one very small function you can spit out a list of values, separated conveniently by rows and columns. Then you can take this list and use it however you want, perhaps in a DataTable or GridView object.
 
Read More »

Posted in C#, All Tutorials | 11 Comments »

Apr
16

CSS Snippet Tutorial - Importing Style Sheets

Cascading Style Sheets, when used properly, do a great job of tidying up messy HTML, but have you ever felt like your CSS need some refactorization of its own? And sometimes, as part of that refactoring, it would be nice to split your CSS into multiple files - but now your thinking to yourself "well, that's no good, now I'll have some css files that depend on others and I will need to remember what needs what when I'm writing new html pages." Fortunately, the designers of CSS felt your pain, and so added the @import rule into CSS2.
 
Read More »

Posted in CSS, All Tutorials | No Comments »

Apr
14

Flex - Rotating Cube ViewStack Component

Today I am going to show and give out a cool component I have built. The component is built to make it easy to use Alex Uhlmann's Distortion Effects in a ViewStack based component to rotate to the sides. I will show an example application and how to use the component, CubeEffect. Hopefully someone out there will find a good use for the component or at least some use of the source provided here.
 
Read More »

Posted in Flex, All Tutorials | 10 Comments »

Apr
11

C# Tutorial - Extension Methods

Today, we are going to take a look extension methods, which is a language feature introduced to C# in .NET 3.0. Extension methods are a piece of syntactic sugar that allow you add new functionality to a class that you don't have direct access to. Sound cool yeah? Cause it is.
 
Read More »

Posted in C#, All Tutorials | 1 Comment »

Apr
9

WinForms - Painting On Top Of Child Controls

If you have worked with WinForms and ever needed to do some custom painting, I'm sure you have had the following happen. You write up some painting logic, and run the program, only to find that all or part of the painting is not visible. You scratch your head for a moment and then go "Duh! There's another control on top of what I'm trying to paint!", and then go off and try and figure out a different solution. Today I'm going to show you a way of getting around this problem in certain situations.
 
Read More »

Posted in C#, All Tutorials | No Comments »

Apr
7

Silverlight DataGrid - The Basics

I finally downloaded and started using Silverlight 2.0. In a nutshell, it's worlds better than Silverlight 1.0 and 1.1. Of all the new controls we now have access to, the one I was most interested in seeing was the DataGrid. WPF doesn't even have a DataGrid (if you don't count the ListView with a GridView applied), so I surprised when I learned Silverlight was shipping with one. This tutorial is going to introduce you to the DataGrid and demonstrate how to populate it with data from an RSS feed.
 
Read More »

Posted in Silverlight, All Tutorials | 10 Comments »

Apr
4

Flex & Degrafa Tic Tac Toe Tutorial Series Introduction

I have started playing around with