Skip to main content

Posts

Showing posts with the label WinForms

C# Tutorial - How To Use Custom Cursors [Intermediate]

Custom cursors are something that you don't need to use very often, but when you do need them, they can make a huge difference in the usability of your program. So today we are going to take a look at how to use your own custom cursors in C#/WinForms applications (don't worry, WPF aficionados, we will take care of you at a later date). Changing the cursor on a WinForms control is extremely easy, as long as you are only trying to change it to one of the other standard cursors. To do that, all you need to do is set the Cursor property on your control to one of the cursors on the Cursors object. However, using a cursor of your own can be a little more difficult. There are a couple ways to use your own cursors, and they all eventually create a new Cursor object. The simplest way is to just load a cursor file (you know, the ones with the ".cur" extension) that you created. The constructor for the Cursor can take a file path to do just that: Cursor myCurso...

C# - Using WPF In WinForms [Beginner]

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. You might be thinking to yourself "why would someone want to do that?" A great question, and there are a couple different reasons. First, perhaps you have an application already written in WinForms, but you want to move to WPF. Instead of rewriting the entire thing from scratch (which might be a large amount of work, and might be time/cost prohibitive), you can rewrite portions of the application as time allows or when you need to redo a particular section anyway. Another reason would be if there is a area of your app that would be easy to do in WPF (maybe because of the animation features, or the composibility) while in WinForms it would be difficult. So what do we need to do to enable this i...

C# - Using WinForms In WPF [Beginner]

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. We are going to take a look at both embedding WinForms using C# code and using XAML - both have their own advantages and disadvantages. The WinForms control we are going to be using is the DataGridView - a powerful WinForms control that does not have a comparable WPF control (although, the service pack update to WPF coming this summer will include a DataGrid - possibly eliminating the need for embedding the WinForms version). There are some drawbacks for embedding, and we will address those as well. So the first thing that we need to do (after creating a new ...