avatar

Andres Jaimes

How to create a simple gradient in C#

Creating a simple gradient using two colors is very simple:

1Rectangle rect = new Rectangle(0, 0, 100, 100);
2LinearGradientBrush lgb = new LinearGradientBrush(rect, Color.White, Color.Blue, 90);
3e.Graphics.FillRectangle(lgb, rect);

This code will …

Printing in C# – The easy way

Believe me, it is easy. As with any class, before we can use any of the Classes, Events and Objects available to us in the .Net Framework we need to import the Namespaces we need. For this we need 3 namespaces. VB.Net users only required 2 because …

How to choose a printer using C#

You can assign a printer and other settings by using the basic PrintDocument and PrintDialog controls properties. Look at the next example:

1if (printDialog.ShowDialog() == DialogResult.OK) {
2    printDocument.PrinterSettings.PrinterName = …