Tuesday, December 7, 2010

Notepad - Right to Left

Today, while typing in notepad I faced a strange problem, my typing order just got reversed. I was typing fro m left to write and it changed to right to left. After some googling i found that it  is due to s accidental pressing of notepad shortcut Cntrl+RightShift.

So if You want to right to left in Notepad then use shortcut:
Cntrl+RightShift Key

if You want to left to right in Notepad then use shortcut:
Cntrl+LeftShift Key

As per following Wiki Link:
http://en.wikipedia.org/wiki/Notepad_%28software%29
Notepad supports both left-to-right and right-to-left based languages, and one can alternate between these viewing formats by using the right or left Ctrl+Shift keys to go to right-to-left format or left-to-right format, respectively.

Monday, December 6, 2010

LINQ - Beginners Tutorial-2

Here we will start using some advance operators and will write code as lambda expressions as well as comprehension query.

Input:
string[] names = { "Ajay", "Vijay", "Karan", "Farhan", "Pooja", "Geeta", "Dia" };

Lambda Expression:
IEnumerable tp = names.Where(n => n.EndsWith("a"))
                            .OrderBy(n=> n.Length)
                            .Select(n => n.ToUpper());


Comprenesion Query:
IEnumerable tp = from n in names
                         where n.EndsWith("a")
                         orderby n.Length
                         select n.ToUpper();  
 

Enumerate result:
foreach (string str in tp)
{
     Console.WriteLine(str);
}


Output:
DIA
POOJA
GEETA

Main Points:
1. We have option to use either lambda expressions or comprehension query to get the desired result.
2. Compiler converts comprehension query to lambda expression.

Sunday, December 5, 2010

LINQ - Beginners Tutorial-1

What is LINQ?
LINQ stands for Language integrated Query, that allows us to query local object collection or remote data source.

Using LINQ we can query any collection implementing IEnumaerable interface. To use LINQ in code we need to use Sysrtem.Linq namespace.

First Example:
string[] names = { "Ajay", "Vijay", "Karan", "Farhan", "Pooja", "Geeta" };
IEnumerable tp = names.Where(n => n.EndsWith("a"));
foreach (string str in tp)
{
Console.WriteLine(str);
}


Here we have taken a string array in first line of code, fnames that contains 6 names.
In second line of code we write a Linq to get the names ending with "a".

Output:
Pooja
Geeta

Main Points:
1. Linq data has two parts, sequence and elements. Here names is a sequence and array members are elements.
2. Linq doesn't alter the input sequence. So result will always be in the order it was input.
3. Linq always return an IEnumerable result.
4. "n => n.EndsWith("a")" is a lambda expression that filters the result for us.

Monday, September 20, 2010

Enable a hard disabled Excel 2003 Add-In

Follow following steps to enable a hard disabled Excel 2003 Add-In

1. Launch Excel.
2. On the Help menu, click About Microsoft Office Excel.
3. Click Disabled Items.
4. Select the add-in and click Enable.
5. Click Close.

Enable a hard disabled Excel 2007 Add-In

Follow following steps to enable a hard disabled Excel 2007 Add-in.

1. Launch Excel.
2. In the application, click the Microsoft Office Button. Click Excel Options button.
3. In the categories pane, click Add-ins. In the Manage box, click Disabled Add-ins, and then click Go.
4. Select the add-in and click Enable.
5. Click Close.

Friday, June 11, 2010

How Platform target: switch works?

Platform Target
Platform target switch is used to generate assemblies for 32 bit, 64 bit or for both (that can be used on 32 as well as 64 bit machine)

Switch:
x86: Generate assemblies for 32 bit platform.
x64: Generate assemblies for 64 bit platform.
Any CPU : Generate assemblies for 32 bit as well as 64 bit platform.

Example:
Lets suppose I have some exe's and dll's generated using these switches.

EXE                                 DLL                                       Switch
Myx86.exe                       Myx86.dll                                - x86
Myx64.exe                       Myx64.dll                                - x64
MyAnyCPU.exe               MyAnyCPU.dll                       - Any CPU

Running exe on 32 bit machine:

Myx86.exe will act as 32 bit application and can refer Myx86.dll and MyAnyCPU.dll but will give exception for Myx64.dll

Myx64.exe will give an exception.

MyAnyCPU.exe will act as 32 bit application and can refer Myx86.dll and MyAnyCPU.dll but will give exception for Myx64.dll

Running exe on 64 bit machine:

Myx86.exe will will act as 32 bit application and can refer Myx86.dll and MyAnyCPU.dll but will give exception for Myx64.dll

Myx64.exe will act as 64 bit application and can refer Myx64.dll and MyAnyCPU.dll but will give exception for Myx86.dll

MyAnyCPU.exe will act as 64 bit application and can refer Myx64.dll and MyAnyCPU.dll but will give exception for Myx86.dll

Thursday, June 10, 2010

Window Form Event Order

Application Startup Events

Control.HandleCreated

Control.BindingContextChanged

Form.Load

Control.VisibleChanged

Form.Activated

Form.Shown

Application Shutdown Events

Form.Closing

Form.FormClosing

Form.Closed

Form.FormClosed

Form.Deactivate