WinForms

C# Dialogs, Part 2 - Custom Dialogs


Posted in:

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 Icon Read More

C# Dialogs, Part 1 - MessageBox


Posted in:

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 Icon Read More

C# Snippet Tutorial - The Web Browser Control


Posted in:

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 Icon Read More

WPF Tutorial - Using WPF In WinForms


Posted in:

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 Icon Read More

WPF Tutorial - Using WinForms In WPF


Posted in:

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 Icon Read More

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


Posted in:

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 Icon Read More

Taking Some Screenshots with C#


Posted in:

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 Icon Read More

WinForms Tutorial - Manage Your Own Double Buffering


Posted in:

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 Icon Read More

WinForms - Painting On Top Of Child Controls


Posted in:

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 Icon Read More

WinForms - Accessing Mouse And Keyboard State


Posted in:

Generally, Windows programs are very event based systems - a user presses a key, the key down event is fired with the information on what key was pressed, and the application reacts accordingly. There are sometimes cases, however, when the program needs to know the current state of the mouse/keyboard, but we don't have a handy event with the info about which keys are down or mouse buttons are pressed. Now you could always maintain this state yourself in some sort of data structure and updating it on key/mouse up and down events - but that is a lot of work, and, as it turns out, unnecessary. There are already functions built into .NET that let you access most (but not all) of this info - and in the case where there is not a built in function, the answer is just a simple interop away! And that is what we are going to take a look at today.

Read More Icon Read More

Sponsors