Windows Phone Developers

Wednesday, January 7, 2009

The left-hand side of an assignment must be a variable, property or indexer

The left-hand side of an assignment must be a variable, property or indexer

Assignment in conditional expression is always constant; did you mean to use == instead

The error mostly pops when a VB programmer codes in C#.

To fix this error, make sure that all operators are on the right-hand side and that the left-hand side is a variable, property, or indexer. Use == for checking values instead of ‘=’

if (String.IsNullOrEmpty(s1) == true)

instead of

if (String.IsNullOrEmpty(s1) = true)



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 set Default Button in Windows Form using C#

Default Button in Windows Forms using .NET

This property enables you to designate a default action to occur when the user presses the ENTER key in your application. The button assigned to this property must be an IButtonControl that is on the current form or located within a container on the current form.

You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ENTER key when they are finished instead of manually clicking the accept button with their mouse.

The accept button might not be activated if the currently selected control on the form intercepts the ENTER key and processes it. For example, a multiline text box control allows the ENTER key to be pressed when it is selected to insert a new line character in the control.

this.AcceptButton = buttonOK;


Windows forms Accept Button

For doing the same in VB.Net
Refer : http://dotnetdud.blogspot.com/2007/06/vbnet-setting-default-cancel-buttons.html

And for doing the same in VB/VBA please refer : Setting Default & Cancel Buttons in VBA/Visual Basic 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

Cancel Button in Windows Forms (C#)

The cancel button for a form is the button control that is clicked whenever the user presses the ESC key. The button assigned to this property must be an IButtonControl that is on the current form or located within a container on the current form.

This property allows you to designate a default action to occur when the user presses the ESC key in your application. You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ESC key to close a window without committing changes instead of manually clicking the cancel button with their mouse.

this.CancelButton = buttonCancel;


Cancel Button in Windows Forms (C#)


For setting the same in VBA/VB refer : http://vbadud.blogspot.com/2007/06/setting-default-cancel-buttons-in.html

See also Setting Default & Cancel Buttons in VBA/Visual Basic 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 Existing Instance of Excel in C#



C# GetObject Method

Marshal.GetActiveObject gets a running instance of the specified object from the Running Object Table (ROT).

using System.Runtime.InteropServices;

using Excel = Microsoft.Office.Interop.Excel;

private void GetExcel()

{

try

{

oXL = (Excel.Application)Marshal.GetActiveObject("Excel.Application");

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

Marshal.GetActiveObject exposes the GetActiveObject COM API method from OLEAUT32.DLL; however, the latter expects a class identifier (CLSID) instead of the programmatic identifier (ProgID) expected by this method. To obtain a running instance of a COM object without a registered ProgID, use platform invoke to define the GetActivateObject COM method


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 Disable Minimize Button on Windows Forms using C#

How to Disable Minimize Box on Windows Forms using C#

A Minimize button enables users to minimize a window to an icon. To display a Minimize button, you must also set the form's FormBorderStyle property to FormBorderStyle.FixedSingle, FormBorderStyle.Sizable, FormBorderStyle.Fixed3D, or FormBorderStyle.FixedDialog.

To enable or disable the minimize button, you can use

this.MinimizeBox = false;

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 Disable Maximize Button on Windows Forms using C#

Disable/Enable Maximize Box on Windows Forms


A Maximize button enables users to enlarge a window to full-screen size. To display a Maximize button, you must also set the form's FormBorderStyle property to FormBorderStyle.FixedSingle, FormBorderStyle.Sizable, FormBorderStyle.Fixed3D, or FormBorderStyle.FixedDialog.


A Maximize button automatically becomes a restore button when a window is maximized. Minimizing or restoring a window automatically changes the restore button back to a Maximize button.


To disable Maximize button


this.MaximizeBox = false;





Windows form Maximize Box

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 check if the OpenDialog is cancelled

How to check if the OpenDialog is cancelled

To check if the OpenDialog is cancelled try the following code

if (openXLFile.ShowDialog() == DialogResult.Cancel) {

MessageBox.Show("You have cancelled the dialog! Please select a file");

}

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