C# – Check if Form is already running

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.

C# Auto click button and auto fill form

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!

da-app

To show you how autoclick/autofill works we’ll make a simple Google AutoSearch Bot.

So lets begin… Continue reading

Convert color to hex using C#

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

How to remove selection rectangle using CSS

recty

Have you ever noticed that when you click a link (in Firefox,IE etc) a dotted rectangle appears around it? (see the image above)

I don’t have a problem with it. But if you find it boring and want to get rid of it. Then I’ve the best solution for you. You can get rid of it with one line of code.

All you have to do is to insert this into your CSS:

* { outline: none; }

And those rectangles (or outlines) will never appear again.

Screen Capture Application using C#

Screen Capture Application

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: Continue reading

Draw a Rectangle in C# using Mouse

Draw a Rectange in C# using Mouse

This tutorial will show you how to draw rectangle in C# using Mouse. You can normally draw a rectangle by putting the values manually. But that doesn’t always work. Sometimes you’ll require the rectangle to be drawn automatically (without putting values manually). This tutorial will show you how to do that. Let’s begin: Continue reading

Drag and Drop using C#

I was working on an App and needed Drag & Drop support for it. I thought it’ll be complicated but its very easy. Here’s how its done:

For this tutorial I’ll be using a listBox. You can use any control but make sure you set the “AllowDrop” to “true“.

Checking what has been dragged

Select the listBox and add the DragEnter event.

Add this code:

private void listBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
 {

 // This will make sure that a file has been dropped and not text,folders or something else

 if (e.Data.GetDataPresent(DataFormats.FileDrop, false))

 {

 // This will allow the files to be dragged into the control

 e.Effect = DragDropEffects.All;

 }

 }

The above code first makes sure that files are dragged and not text, folders etc; and then allows the files to be dragged into the control.

Continue reading

New Design!

Finally! The new design is up. I designed / coded this myself.

I love blue and simplicity. And yeah! Web 2.0′ish too.