Wednesday, May 25, 2011

Free C# Book

In this book, you will learn how to write and compile C# programs, understand C# syntaxes, data types, control flow, classes and their members, interfaces, arrays, and exception handling. After completing this book, you should have a clear understanding of the purpose of C# language, it’s usages, and how to write C# programs.

http://www.c-sharpcorner.com/UploadFile/mahesh/csp08202007084545AM/csp.aspx

Tuesday, May 24, 2011

Why Every Developer Should be a Good Tester

I have seen repeatedly, a developer a.k.a. programmer a.k.a. coder assumes that testing is not a part of his day-to-day job. His job is just write code and passes it to the testing team and the testing team will find all bugs and problems in the code.

http://www.c-sharpcorner.com/Blogs/5266/why-every-developer-should-be-a-good-tester.aspx

Monday, May 16, 2011

Add X-Power to Your XML Development with Liquid XML Studio 2011

Today, more and more applications are migrating to the Web and the Cloud services are taking over the world; XML has become one of the key and vital parts of the data exchange mechanism. Whether you are developing client centric applications or building a consumer product, you will end up working with XML.

http://www.c-sharpcorner.com/uploadfile/mahesh/7411/ 

Saturday, May 14, 2011

Google Chromebook: Windows, iPad Killer or Just one more Tablet

Google Chromebook: Windows, iPad Killer or Just one more Tablet

Long awaited and announced Google Chromebook will hit stores (Best Buy) on June 15. So what makes Chromebook different than other tablets?

Sunday, April 3, 2011

C# TabControl

TabControl Control

The TabControl manages tab pages where each page may host different child controls. In this article, I will demonstrate how to create and use a TabControl in Windows Forms.

I wrote an article Working with Windows TabControl with C# in 2003 using .NET 2.0 and since then, things have been changed. This article is written using Visual Studio 2010.

Creating a TabControl

We can create a TabControl control using a Forms designer at design-time or using the TabControl class in code at run-time or dynamically.

Design-time

To create a TabControl control at design-time, you simply drag and drop a TabControl control from Toolbox onto a Form in Visual Studio. After you drag and drop a TabControl on a Form, the TabControl1 is added to the Form and looks like Figure 1.


TabControl1.gif

Figure 1

A TabControl is just a container and has no value without tab pages. As you can see from Figure 1, by default two Tab Pages are added to the TabControl. We can add and remove tab pages by clicking on the Tasks handle and selecting Add and Remove Tab links as you see in Figure 2.


TabControl2.gif

Figure 2

Add Tab link adds next tab page and Remove Tab removes the current tab page from a Tab Control. We will discuss tab pages in more details later in this tutorial.

Run-time

TabControl class represents a tab control. The following code snippet creates a TabControl and sets its Name, BackColor, ForeColor, Font, Width, and Height properties.

C# Code:

// Create a TabControl and set its properties

TabControl dynamicTabControl = new TabControl();
dynamicTabControl.Name = "DynamicTabControl";
dynamicTabControl.BackColor = Color.White;
dynamicTabControl.ForeColor = Color.Black;
dynamicTabControl.Font = new Font("Georgia", 16);
dynamicTabControl.Width = 300;
dynamicTabControl.Height = 200;

Once the TabControl control is ready with its properties, we need to add it to a Form by calling Form.Controls.Add method. The following code snippet adds a TabControl control to the current Form.
C# Code:



Context Menu in C#

ContextMenuStrip Control

The ContextMenuStrip control provides functionality of context menus in Visual Studio 2010 and .NET 4.0. A context menu is also known as a popup menu. A context menu appears when you right click on a Form or on a control.

In the previous versions of .NET, the context menu functionality was provided by the ContextMenu control. In .NET 4.0, the ContextMenu control is replaced with the ContextMenuStrip control.

In this article, we will discuss how to build context menu enabled Windows applications using ContextMenuStrip control in Visual Studio 2010.
Creating a Context Menu
To create a ContextMenuStrip control at design-time, you simply drag and drop a ContextMenuStrip control from Toolbox onto a Form in Visual Studio. After you drag and drop a ContextMenuStrip on a Form, the ContextMenuStrip1 is added to the Form and looks like Figure 1. Once a ContextMenuStrip is on the Form, you can add menu items and set its properties and events. If you noticed in Figure 1, first item of the ContextMenuStrip has text Type Here. You can actually start typing here.
ContextMenu1.gif
Figure 1
If you notice in Figure 2, I type couple of menu items. As soon as you select a menu item, you will see automatically sub menu items areas are editable and you can keep going as many levels you like. I add two menu items and two sub menu items.
ContextMenu2.gif
Figure 2
We can also create context menus at run-time. Even though you can create a ContextMenuStrip at run-time, it is recommended you create at design-time and then set the properties and methods at run-time.
First step to create a dynamic ContextMenuStrip is to create an instance of ContextMenuStrip class. The following code snippet creates a ContextMenuStrip control object.
C# Code:
ContextMenuStrip PopupMenu = new ContextMenuStrip();
VB.NET Code:
Dim PopupMenu As New ContextMenuStrip()
In the next step, you may set properties of a ContextMenuStrip control. The following code snippet sets background color, foreground color, Text, Name, and Font properties of a ContextMenuStrip.
C# Code:
PopupMenu.BackColor = Color.OrangeRed;
PopupMenu.ForeColor = Color.Black;
PopupMenu.Text = "File Menu";
PopupMenu.Font = new Font("Georgia", 16);
VB.NET Code:
PopupMenu.BackColor = Color.OrangeRed
PopupMenu.ForeColor = Color.Black
PopupMenu.Text = "File Menu"
PopupMenu.Font = New Font("Georgia", 16)
Once the ContextMenuStrip control is ready with its properties, the next step is to add the ContextMenuStrip to a Form. To do so, first we set ContextMenuStrip property and then use call the Show method to display the ContextMenuStrip.
The following code snippet adds a ContextMenuStrip control to the current Form and displays it when you right click on the Form.
C# Code:
this.ContextMenuStrip = PopupMenu;
PopupMenu.Show();
VB.NET Code:
Me.ContextMenuStrip = PopupMenu
PopupMenu.Show()

Setting ContextMenuStrip Properties
After you place a ContextMenuStrip control on a Form, the next step is to set properties.