I was working on an application which checked for updates. I used WebRequest/WebResponse for checking updates. It showed a continuous Progressbar while checking for updates. But there was a problem. It worked properly when you were connected to internet but it just showed the progressbar all the time if not connected.
The solution for that was to check for internet connection before checking for updates. If connected then check for updates otherwise show an error.
Checking for the state of internet connection is very simple.
Firstly, import System.Runtime.InteropServices namespace. Add this to the top of your code:
using System.Runtime.InteropServices;
Then use this code for checking connection state:
For C# Beginners: Add this code above or below public Form1() { … }
// API Method
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
// A method for checking the state
public static bool IsConnected()
{
int Description;
return InternetGetConnectedState(out Description, 0);
}
Now you can use the above method to check for connection before doing anything that requires internet connection.
Example use:
// If internet connection is active
if (IsConnected())
{
// do something
}
else
{
MessageBox.Show("Please connect to the internet.");
If you have any questions please don’t hesitate to post a comment.

There are times when you’ll need an autocomplete textbox. Autocomplete textbox makes the user’s life easier. It shows suggestions as the user types. In case of a web browser, if you type “goo” it will automatically show all the suggestions starting with or containing “goo” like “Google, Goofy” etc. Enough talk! Lets get on with it.
Fortunately, textbox has a built-in autocomplete feature! We don’t have to do any coding.
You can either set it up from the Designer (if you are using Visual Studio or #Develop) or do it via code. It is simple both ways. Lets do it!
Setting up AutoComplete

For setting up autocomplete you’ll have to use three properties of the TextBox class — AutoCompleteSource, AutoCompleteCustomSource and AutoCompleteMode. Here’s an explanation of these properties: Read the rest of this entry »
To check if a form is already running you’ll have to look for it in the Application.OpenForms collection. When a form is opened it is added to that collection.
Here’s a boolean method that checks whether a form is open or not :
private bool CheckForm(Form form)
{
foreach (Form f in Application.OpenForms)
if (form == f)
return true;
return false;
}
Example use:
// if form2 is not running
if (!CheckForm(form2))
{
// do something
}
Thanks.
If you have any questions, don’t hesitate to post a comment.

This tutorial will show you how to auto fill forms and click buttons in a website using the webBrowser control. When you learn to do this you can make your own web bots!
To show you how autoclick/autofill works we’ll make a simple Google AutoSearch Bot.
So lets begin… Read the rest of this entry »
So you want convert a .NET color to hex or a hex color to .NET color. Well, its very easy to do this. We won’t have to write lots of code or a special class for it. Thanks to ColorTranslator class. We can convert between these with only 1 line of code. Here’s how its done:
To convert a Hex color to .NET color use this code:
Color color = ColorTranslator.FromHtml("#000000");
For converting a .NET color to Hex color, use thise code:
Color color = Color.FromArgb(0, 100, 50, 100);
// Get the hex color
string HexColor = ColorTranslator.ToHtml(color);
That was simple & easy. If you have any questions don’t hesitate to leave a comment.
Thanks

A detailed tutorial about creating an Image Viewer or Picture Viewer application in C#. This application also converts Images from one type to another.
Following are the features of this application:
- Open / Save images.
- Convert images.
- Rotate Images.
- All popular image formats are supported.
Let’s get started! Read the rest of this entry »

A class that will help you take screenshots quickly and easily.
Following are the features of this class: Read the rest of this entry »

This is a detailed tutorial about making a simple Screen Capture (Screenshot Capture) application in C#. The features are: Take screenshot, view it and save it. We will be making a simple application but if you are little bit good with C# then you can enhance it and make it much better.
Setting up the Form
For this tutorial we will need 2 buttons, a timer, SaveFileDialog and a PictureBox. Here’s the info: Read the rest of this entry »