Windows Phone Developers

Sunday, January 25, 2009

A simple StatusStrip Control Example using C#

C# StatusBar Example

Status bars play an important part in informing the user of the use of controls, the status of progress of the application etc. .Net provides a new control – the StatusStrip control – an extension of StatusBar

Let us have a small Windows form like the one as shown below.

Select the StatusStrip control in the ToolBox and drop it on the form




When you drop the control will be placed on the Tray below the form and a StatusStrip with a ToolStripLabel will be added to the Form






Now the ToolStripLabel can be used to apprise the user of the context and progress as shown below

private void buttonSelectXL_MouseHover(object sender, EventArgs e)

{

toolStripStatusLabel1.Text = "Click the Button to select the file";

}






.NET StatusBar Example, .NET ToolStripLabel Example

See also : Hide Excel Status Bar / Show Excel Status Bar using VBA

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

How to use C# MouseOver Events in Windows Forms

Yet again we take the good old select file form as our example. Let us use the MouseHover event of the ellipsis button to inform the user of its function.



To add an function to handle the event, click the event tab of the button and scroll to MouseHover event and double click it.

Add the following code to the event procedure.

private void buttonSelectXL_MouseHover(object sender, EventArgs e)

{

toolStripStatusLabel1.Text = "Click the Button to select the file";

}

The toolstrip label will be updated whenever the mouse pointer is hovered over the ellipsis button.





Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

C# Array UBound Function

How to get the Upper Bound of an Array in C#

The upper bound of the array can be retrieved using the Length property as shown below:

private void GetUbound()

{

String[] arTemp = {"First","Second"};

MessageBox.Show (arTemp.Length.ToString ());

}

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

OpenFileDialog in C# - How to Use OpenFileDialog in C# Windows Application

Common Dialog in C# (.NET)

CommonDialog was widely used to select the files in Visual Basic 6.0. .Net provides a OpenFileDialog component, which can be used for the same.

Let us have a small Windows form where the file to process is to be selected. The form contains a CommandButton to invoke the Open File dialog box and a TextBox to display the selected file.





To use the OpenFileDialog, insert the component from Toolbox to the form



When it is droped to a form, the OpenFileDialog component appears in the tray at the bottom of the Windows Forms Designer.





Now write the following code in the Button’s Click event to display the Open file dialog box

private void buttonSelectXL_Click(object sender, EventArgs e)

{

openXLFile.Filter = "Microsoft Excel Workbooks (*.xls)*.xls";

if (openXLFile.ShowDialog() == DialogResult.OK )

{

String sFileName = openXLFile.FileName;

txtExcelFile.Text = sFileName;

}

else

{

MessageBox.Show("Please select a file");

}

}







The above code filers only Excel files in the Open Dialog Box

The selected file will be displayed in the Textbox


See also OpenFileDialog in Visual Basic .Net

For CommonDialog implementation in VB6.0 refer http://vbadud.blogspot.com/2007/06/visual-basic-common-dialog.html Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

How to Add Resources to C# Windows Application

How to add images as resources to C# Windows Application


Resources can be added to the C# Project using Resource Page in the Project Designer (Project à Project Properties)

The Resources page of the Project Designer hosts an instance of the Resource Designer that stores and maintains resources in a single location (Resources.resx).

The Resource Designer is language-neutral and supports projects in all Visual Studio languages. Items that you add to the project by using the Resource Designer are placed in the Resources directory for your project. The designer information is stored in a file named Resources.resx, and code for the resource is stored in Resources.Designer.cs, Resources.Designer.vb, or Resources.Designer.jsl.










Right Click the Resources section in the solution explorer and Select Add à Existing Item and select the Image files that need to be added






The images will be added as shown below






Drag the images to the Resources page – Rename the resource names if needed




Now you can use the Resources in your Form. Select the BackGroundImage from the Form’s properties box – Click on the ellipsis next to the BackGroundImage property. This will open the Select Resource dialog Box





Select appropriate resource from the list



The same can be set through code using

this.BackgroundImage = Properties.Resources.User_Single

For linkedresources see - Create HTML Message with Embedded Images in VB.NET / Embed images in HTML mail message using VB.NET









































Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Cannot find wrapper assembly for type library "Microsoft.Office.Core".

Cannot find wrapper assembly for type library "Microsoft.Office.Core".


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

There are updated custom wrappers available for the following referenced components: Office.

There are updated custom wrappers available for the following referenced components: Office.



Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon