Friday, August 26, 2011

How to Print First Row or Header Row on Every Page in Excel?

Go to this site for know the steps in Excel 2007/2010:  http://www.lytebyte.com/2009/08/18/how-to-print-first-row-or-header-row-on-every-page-in-excel/

In Excel 2003:

1) Go to View Menu bar
2) Click Header and Footer
3) Go to Sheet Tab
4) Click Rows to repeat at top option in Print titles
5) Select First row by clicking at position Row1 and Press enter
6) Now prints the page. You will get desire output.


Interesting Programs at beginner stage


1. Write a c program without using any semicolon which output will : Hello word.

2. Swap two variables without using third variable.

Solution: 1
void main(){
    if(printf("Hello world")){
    }


Solution: 2
int main(){
    int a=5,b=10;
//process one
    a=b+a;
    b=a-b;
    a=a-b;
    printf("a= %d  b=  %d",a,b);
//process two
    a=a^b;
    b=a^b;
    a=b^a;
    printf("\na= %d  b=  %d",a,b);  



 
Good Collection of C Programs for beginner: http://cquestionbank.blogspot.com/2010/07/c-program-examples.html
  

Good example on OOPs concept in C++
http://www.functionx.com/cpp/examples/index.htm 

Monday, August 22, 2011

Property and events of ListView

These are the following properties and events of ListView:

this.listView1.LargeImageList = this.imageList1;
this.listView1.HoverSelection = true;   //When mouse goes on list item then its highlight.
this.listView1.Activation = System.Windows.Forms.ItemActivation.OneClick;  //When mouse goes on list time then cursor convert into hand.
this.listView1.Sorting = System.Windows.Forms.SortOrder.Ascending;  // List Items arrange accordingly Items name

//Add items into List View
String FilePath = openFileDialog1.FileName;
 imageList1.Images.Add(Image.FromFile(FilePath));
ListViewItem listItem = new ListViewItem(filename,imageList1.Images.Count - 1);
 listView1.Items.Add(listItem);

private void listView1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < listView1.Items.Count; i++)
                if (listView1.Items[i].Selected)
                    MessageBox.Show(listView1.Items[i].Text + " - " + (i + 1).ToString());
              
        }

Take help from this site for examples on ListView: http://www.java2s.com/Code/CSharp/GUI-Windows-Form/ListViewExample.htm



Good Window Controls Example

Monday, August 15, 2011

Quotes


No matter where you read it, or who said it,
no matter if I have said it, unless it agrees with your own
reason

I don't have time 2 hate people who hate me. Because, I'm too busy in loving people who love me.

Shakspear said, " I CRIED WHEN I HAD NO SHOES, BUT STOPPED CRYING WHEN I SAW A MAN WITHOUT LEGS." " LIFE IS FULL OF BLESSINGS BUT WE DON'T UNDERSTAND IT."

Life main 3 factories zaroor lagao
Brain main ice factory
Zuban main sugar factory
Heart main love factory
Phir life hogi SATISfactory

When it rains all birds occupy shelter
But
The eagle avoids rain by flying above the cloud.
Problem is common to all but Attitude makes a difference

Everyone loves a Rose but nobody loves a leaf which adds beauty to the Rose.
Love those who make your life Beautiful not the one who is beautiful

Sangeet sun kar gyaan nahin milta,
Mandir jaa kar bhagwan nahin milta,
Pathar ko log is lie pujte hain,
Kyoon ki
Viswas ke layak insaan nahin milta...

Always share your problems with 1% people who genuinely love you.
Because,
50% people don't care about your problem and 49% people become happy that you have a problem

 




No one in the world is born for you, but u can make someone to live for u` Live the life in such a way tht othrs love to live wd u...

Pahele Abhav me khush rahte the ab khushiyo ka abhav hai

Maine to apna sara farz nibhaya ab khuda bhul gaya to me kya karu

Sunday, August 14, 2011

Investing in What?

Invest in these areas:-

Missing

  
        Auto Ancillaries 0.71%
        Banks 4.09%
        Construction 7.68%
        Consumer Durables 52.04%
        Edible Fat 2.68%
        Engineering 5.21%
        Food Processing 0.10%
        Hospitality 0.58%
        Information Technology 1.49%
        Packaging 3.29%
        Paper 0.07%
        Pharmaceuticals and health care 4.49%
        Plastics 3.22%
        Retail 0.29%
        Service 13.76%
        Sugar 0.12%
        Textiles 0.16%
                                                        99.98%

Income Tax for Salary? and What's the difference between monthly CTC and Take Home

Look into this
1) Salary is broken up into several components, like basic, HRA, special allowance etc. The main reason for doing this is to make your salary tax effective; to ensure that you pay minimum tax on your salary. Here is a run down on the various common components and they are treated according to the tax laws.
Income tax laws attach a certain value to each of these components:
• Residential accommodation
• Use of car
• Services such as that of a gardener, watchman, sweeper or any personal attendant
• Provisions such as gas, electricity or water that is paid by the company
• Any free education or concessional education that the company pays you or your family
• Interest free loans
• Reimbursement of holiday related travel or accommodation expenses
• Festival gifts or vouchers
• Individual club membership
http://wealth.moneycontrol.com/yourstartupkit/income-tax/how-do-taxes-affect-my-salary-/9671/0

2) Understand above theory by an example by this article
http://wealth.moneycontrol.com/features/income-tax/all-you-wanted-to-know-about-ctc-/12042/0 


Particulars Rs (per annum) Income Tax Laws Taxable Rs
Basic 480,000 Fully Taxable 480,000
Dearness Allowance 48,000 This is an allowance given to you to compensate for inflation or rising prices. DA is Fully Taxable. 48,000
Entertainment Allowance 12,000 The taxability of entertainment allowance depends on the company policy. In this case, this is Fully Taxable. However, in some companies, entertainment allowances become tax free if bills are submitted to the extent that these expenses were used towards office purposes. 12,000
House Rent Allowance 96,000 House Rent Allowance (HRA) exemption is applicable only if you are living in a rented house and not in your own house.
There are certain conditions just to ensure that you do not claim a higher rent reimbursement, to get a greater tax benefit.
The minimum of the three amounts will be exempt from tax:
a. Actual HRA allowance in the salary package, that is Rs 96,000
OR
b. HRA received less 10 per cent of salary and DA(480,000 + 48,000), that is (96,000 – 10% of 528,000) = 43,200
OR
c. If you live in metropolitan (Delhi, Chennai, Bombay and Calcutta), 50 per cent of salary and DA However, if you live in any other city, it is 40 per cent of salary + DA.

So, it would be Rs 211,200 (40% of 528,000)

The least amount of the three would be Rs 43,200, which is exempt. That means the actual taxable amount would be
Rs 96,000 - Rs 43,200 = Rs 52,800
52,800
Conveyance Allowance 12,000 You get this allowance to meet your traveling expenses from home to work. An amount of up to Rs 800 per month is exempt from tax. If your employer pays you a monthly conveyance allowance of more than Rs 800, then you will have to submit proofs such as fuel and petrol bills for that excess amount to claim tax exemption.
In this case, Conveyance allowance of Rs 9,600 per annum is exempted from tax. So, Rs 2,400 will be subjected to tax. In some companies, if the balance is used for official purposes, the amount becomes tax free.
2,400
Overtime Allowance 12,000 OA is Fully Taxable. 12,000
Medical reimbursement 15,000 Your company will reimburse the expenditure that you incur on medical expenses for you and your family. This is however restricted to Rs 15,000 per annum.
So, In this case, produce medical bills for a maximum of Rs 15,000 to her employer. If you are allotted a annual medical reimbursement of Rs 20,000, Rs 15,000 would be tax exempt if you submit bills, which means you’d have to pay tax on the remaining amount of Rs 5,000.
0




Gross Salary 675,000
Gross Taxable Salary
607,200
Company’s contribution to provident fund (@ 12% of Basic Salary) 57,600
Tax
Income Tax For women:
Up to 0 to Rs 1.8 lakh: Free            From Rs 1.8 lakh to Rs 3 lakh: 10 per From Rs 3 lakh to Rs 5 lakh: 20 per Above Rs. 5 lakh: 30 per
Education cess is applicable @ 3 per cent on income tax.
 (300,000-180,000)*0.10 + (500,000-300,000)*0.20 + (607,200-500,000)*0.30 = 84160 (Income Tax)
84160+84160*0.03 =     86,685(-)                                            





Annual CTC 732,600
Net annual salary
520,515
Monthly CTC 61,050
      Net monthly salary                       
43,376


Myself Contribution to Provident Fund
4,800(-)


Professional Tax
200(-)


Monthly Take Home
38,376

So while Monthly CTC was Rs 61,050, her take home is just Rs 38,376

How can increase her take home?
If she invests Rs 1 lakh (the limit under section 80 C) in tax saving instruments like PPF, ELSS etc, her annual tax comes down to Rs 55,785.

Gross taxable salary 607,200
PPF(Investment) 100,000
Gross taxable salary 507,200
Tax 55,785 (-)
Net annual salary551,415
Net monthly salary45,951
(Less) Pf contribution4,800 (-)
(Less) Professional tax200 (-)
Monthly take home40,951

It is also important that while she changes jobs, she should take some time to understand the package offered to her to ensure that the CTC is friendly and ensures maximum take home.

3) the Impact of Inflation and Taxes
http://wealth.moneycontrol.com/yourstartupkit/financial-planning/impact-of-inflation-/14772/0 

Whenever you consider an investment option, remember to evaluate the expected rate of return in real terms. In other words, deduct your expected compound annual rate of inflation for the investment period from the compound annual rate of return that you expect from your investment.

For example, say you are considering a bank fixed deposit that promises you an 11% annual rate of return over the next five years and your expectation of inflation during this period is 7% (compound annual).

For this investment, your real compound annual rate of return is only 4%. If your income from this investment attracts a 30% tax rate, then your post-tax real rate of return diminishes further to 0.7% only!  

PPF: http://www.moneycontrol.com/news/tax/ppf-astax-saverinvestment-option_567272.html
http://www.moneycontrol.com/news/economy/ppf-rate-may-risedo-we-have-money-to-save_556031.html

Saturday, August 13, 2011

Restructure your loans to earn financial freedom

Came across this article on dna....good one

Restructure your loans to earn financial freedom

Ravi and Kavitha wanted to start a small business. Both had well-paying corporate jobs, but business was what they wanted to do. They had a sound business plan ready and had even spoken to a few people, who were willing to fund the project. But they could not get around to quitting their jobs, as they had some loan to pay off. This was depressing them.

They were willing to make a few lifestyle changes, but they were not sure if the business would earn enough to pay the loan EMIs.

The fear of defaulting on their loans and struggling to make ends meet deterred them from pursuing their dream.

So they decided to meet a financial planner friend for help to get out of loans.

Based on his advice, they set a Rs5 years - zero loans� target. They also decided not to take any more loans.

This is how they went about it. They listed down all their loans - five in all.

1. Home loan � Rs20 lakh. Current outstanding: Rs15.5 lakh. EMI: Rs18,500. Interest rate: 9.5%. Tenure pending: 11 years

2. Credit card (Ravi) � Rs75,000. Paying minimum balance every month.

3. Car loan (Ravi) � Rs2.5 lakh. Current outstanding: Rs1.5 lakh. EMI: Rs6,500. Tenure pending: 2 years

4. Credit card (Kavitha) � Rs35,000. Paying minimum balance every month.

5. Personal loan (Kavitha) � Rs1,00,000. Current outstanding: Rs65,000. EMI: Rs2,750. Tenure pending: 23 months.

They had Rs18.75 lakh as liabilities. They were paying Rs32,500 monthly towards loan repayment. As per this, they would be out of loans in 11 years.

5 years - zero loans
Both had got an annual bonus of Rs25,000 each and were considering whether to use it towards loan repayment or invest it.

They had a contingency fund of Rs10,000 monthly for long-term needs. This year, after getting their increments, they were willing to commit another Rs5,000 towards repaying their loans.

The contingency fund cannot be utilised for any other purpose. With a total of Rs37,500 available for repaying loans, and a lump sum of Rs50,000 at hand, what is the best way to get out of loans as soon as possible?

The steps
1. They will have to target the most expensive loans first. Two credit card loans of Rs1,10,000 will take another five years on minimum balance payment. The interest rates charged could be as high as 2.99% per month (36% per annum). Hence, use the Rs50,000 bonus to repay one credit card to begin with.

2. Credit card outstanding is now Rs25,000 on Ravi�s card and Rs35,000 on Kavitha�s card. Ravi was paying Rs3,500 on his card till the previous month. Now he will have to increase repayment on card by Rs5,000 (committed amount). Repay Rs8,500 on the card. In three months, Ravi�s card will be paid off in full.

3. Next target is Kavitha�s card. She has been paying Rs1,500 towards that credit card. The amount of Rs8, 500, which was earlier used by Ravi to pay for his card, can be added to this Rs1,500 and totally Rs10,000 can be used to pay off Kavitha�s card. That will be done in 4 months.

Now, with two loans done and Rs10,000 additional cash flow after seven months of the start of project �debt-free�, they now target the next most expensive loan � the personal loan. Now, the loan outstanding would be Rs47,000.

4. The additional Rs10,000 can be saved in the bank for four months and the personal loan can be settled in 4 months.
After this, the amount available to repay loans would be Rs10,000 + Rs2,750 = Rs12,750. The time elapsed since start of project: 11 months.

5. Next target is car loan. Current outstanding 11 months after start of project is Rs1 lakh. Already repaying towards this loan: Rs6,500 per month. Start a six month recurring deposit of Rs12,500 with the bank. At the end of six months, the maturity amount of Rs75,000 can be used to settle the car loan in full.

Now, amount available to repay loans would be Rs12,500 + Rs6,500 = Rs19,000. Time elapsed since start of project: 1 year and 5 months.

6. Final target is home loan. It has been 10 years since they took this home loan. Current outstanding: Rs14.7 lakh. Ravi and Kavitha should make a visit to the home loan company/bank and inform their willingness to increase the EMI on their loan by Rs19,000 from Rs18,500 to Rs37,500. Most banks will be willing to reschedule the loan as long as they are convinced about the repaying capacity of the borrowers. With the new EMI, the home loan will be over in another 37 months (3 years and 1 month).

Bingo! All loans would be over in 4 years and 6 months. Huge amounts saved on interest.Like the famous saying goes, �Freedom is not granted, but rather earned�, Ravi and Kavitha spent half an hour on planning and followed through with the plan diligently to earn their freedom from debt!

Wednesday, August 10, 2011

Left Outer Join in SQL

Take an example to understand use of this:-  There are two tables. In one table VillageName column is there (which is master) and another table has VillageName and ActiveWorker columns. Now Requirement is Show the all villages where each village should show with Active Worker details if exist in table 2 otherwise show details empty with villagename.

select t1.VillageName, t2.ActiveWorker from table t1 left outer join table t2 on t1.VillageName=t2.VillageName

Monday, August 8, 2011

Sending mail using Outlook in C#


Follow following Steps:
1) Add references from COM tab: Microsoft Outlook 9.0 Objecr library
2) Add following line at the top of the file
using Outlook = Microsoft.Office.Interop.Outlook;
3)  Add this method:
 private void SendMail()
{
       Outlook.Application oApp = new Outlook.Application();

      Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem));
       email.Recipients.Add("info@gmail.com");
       email.Subject = "hi";
       email.Body = "bye";

       OpenFileDialog attachment = new OpenFileDialog();
       attachment.Title = "Select a file to send";
       attachment.ShowDialog();
      email.Attachments.Add(attachment.FileName,Outlook.OlAttachmentType.olByValue,1,attachment.FileName);
                     
        email.DeleteAfterSubmit=true;//email removed from the outbox after send
        email.Send();

 }

Note: Outlook should be configured (tools -> Email accounts) with valid SMTP details like
          a) Server Information
                  Incoming Mail Server(POP3): mail.microsoft.com
                  Outgoing Mail Server(SMTP): mail.microsoft.com
          b) Email Address: info@microsoft.com
          c) Logon Information
                  UserName: info@microsoft.com
                  Password: *******
          d) Commonly Incoming Server Port: 110 and Outgoing Server port: 25
          e) My Outgoing server require authentication checkbox may be checked.
          f) Connection: Connect via Modem checkbox may be checked.

Guidlines to start C#: Copy and Paste not make you programmer

Taken from here http://www.dreamincode.net/forums/topic/234278-how-to-send-email-on-c%23/#/

 Copy/paste plagiarizing of other people's code you find on the internet does not make you a programmer, coder, software engineer. Let's be clear about that.

Some day when you respect yourself, and show respect to other people's intellectual work you should work on learning to UNDERSTAND how to write your own code from scratch.

I hate to sound disheartening, but if you are this new to C# I think it would be in your interest to work through a book, lessons, tutorials etc. before trying to rush out and build a program from scratch with no experience.

A person does not say "I've never played an instrument nor can I read sheet music: I think I'll go write an opera as a self-teaching experience."



Standard resources, references and suggestions for new programmers.


I would recommend you start with "Hello World" just like the other million+ coders out there. Then work your way up to the more advanced tasks like this.

The problem with taking on large, complex tasks like this when you are new to coding is that
  • it will frustrate you to the point of quitting,
  • you don't know enough about coding to know where to start or in what direction to design your program
  • You risk learning via the 'Swiss cheese' method where you only learn certain bits and pieces for the one project but have huge holes in your education.


I am going to guess that you are trying to teach yourself C# without much guidance, a decent book or without knowing where to look. Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.

But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language through banging on the keyboard experimentation - or you can learn by doing the tutorials and following a good "How to learn C#" book.

Free editions of Visual Studio 2010

May I suggest picking up a basic C# introductory book? There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" type books at your local book seller or even public library.

D.I.C. C# Resource page Start here
Intro to C# online tutorial then here...
C# control structures then here.
MSDN Beginner Developer video series
MSDN video on OOP principals, making classes, constructors, accessors and method overloading
MSDN Top guideline violations, know what to avoid before you do it.
Design patterns as diagrams

The tutorials below walk through making an application including inheritance, custom events and custom controls.
Bulding an application - Part 1
Building an application - Part 2
Quick and easy custom events
Passing values between forms/classes

Working with environmental variables
'Why do we use delegates?' thread

Debugging tutorial
Debugging tips
Great debugging tips
It still doesn't work, article

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.

Microsoft Visual Studio Tips, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5
Has many, many great, real-world tips that I use all the time.

Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on
Writing a text file tutorial.
Reading a text file tutorial.

And everyone always wants to connect to a database, right out of the gate so
Database tutorials right here on DIC

These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio

Have you seen the 500+ MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.

Let me also throw in a couple tips:
  • You have to program as if everything breaks, nothing works, the cyberworld is not perfect, the attached hardware is flakey, the network is slow and unreliable, the harddrive is about to fail, every method will return an error and every user will do their best to break your software. Confirm everything. Range check every value. Make no assumptions or presumptions.
  • Take the extra 3 seconds to rename your controls each time you drag them onto a form. The default names of button1, button2... button54 aren't very helpful. If you rename them right away to something like btnOk, btnCancel, btnSend etc. it helps tremendously when you make the methods for them because they are named after the button by the designer.
    btnSend_Click(object sender, eventargs e) is a lot easier to maintain than button1_click(object sender, eventargs e)
  • You aren't paying for variable names by the byte. So instead of variables names of a, b, c go ahead and use meaningful names like Index, TimeOut, Row, Column and so on. You should avoid 'T' for the timer. Amongst other things 'T' is commonly used throughout C# for Type and this will lead to problems. There are naming guidelines you should follow so your code confirms to industry standards. It makes life much easier on everyone around you, including those of us here to help. If you start using the standards from the beginning you don't have to retrain yourself later.
  • Try to avoid having work actually take place in GUI control event handlers. It is usually better to have the GUI handler call other methods so those methods can be reused and make the code more readible.
    01btnSave(object sender, eventargs e)
    02{
    03    SavePreferences();
    04}
    05 
    06SaveMenuItem(object sender, eventargs e)
    07{
    08    SavePreferences();
    09}
    10 
    11SaveContextMenu(object sender, eventargs e)
    12{
    13    SavePreferences();
    14}
    15 
    16Form1_Closing(object sender, eventargs e)
    17{
    18    if (IsDirty) SavePreferences();
    19}     

Sunday, August 7, 2011

Rounding Number in C#


Below are samples of rounding in C#:

decimal value=12.234;
decimal RoundedValue=decimal.Round(value,2);

Ans: RoundedValue=12.23

If we want to represent 100 like 100.00 by above sample then its not possible. There is another way to represent:

value=100;
decimal RoundedValue=Convert.ToDecimal(value.ToString("F"));

Ans: RoundedValue=100.00

Writing in Excel through C#


Follow the following steps to writing data into Excel through C#:-

1) Add references Interop.Excel.dll in the project (first you need to download this dll)
2) Add this function in the form

using Excel;
using Microsoft;

void excel()
        {
            Excel._Application app;
            Excel.Workbook Wb;
            Excel.Worksheet Osheet;
            Range oRng;
            try
            {
                app = new Excel.Application();
                app.Visible = false;
                //Get a new workbook.
                Wb = (Excel.Workbook)(app.Workbooks.Add(1));
                Osheet = (Excel.Worksheet)Wb.ActiveSheet;
               
                //First row: Header
                for (int i = 1; i <= dataGridView1.Columns.Count; i++)
                    Osheet.Cells[1, i] = dataGridView1.Columns[i - 1].Name;
               
                //Filling Sheet with desired value except Header
                for (int i = 0; i < dataGridView1.Rows.Count-1; i++)
                    for (int j = 0; j < dataGridView1.Columns.Count; j++)
                        Osheet.Cells[i + 2, j + 1] = dataGridView1[j, i].Value.ToString();
                                      
                        //    oRng.Font.Italic = true;
                        //    oRng.Interior.ColorIndex = 15; //     //http://dmcritchie.mvps.org/excel/colors.htm : color indexes list
                                               
                //Setting Font of each Column
                String[] columns = ExcelFont.Split('^');
                for (int i = 1; i <= columns.Length; i++)
                    if (columns[i - 1] == "h")
                    {
                        ((Range)Osheet.Cells[2, i]).EntireColumn.Font.Name = "Kruti Dev 010";
                        ((Range)Osheet.Cells[2, i]).EntireColumn.Font.Size = "12";
                    }
                        
                //First Row: Header
                oRng = Osheet.get_Range(Osheet.Cells[1, 1], Osheet.Cells[1, dataGridView1.ColumnCount]);
                oRng.EntireRow.Font.Name = "Arial";
                oRng.EntireRow.Font.Size = "10";
                oRng.Font.Bold = true;
                //Entire Sheet
                oRng.EntireColumn.AutoFit();

                //Border
                oRng = Osheet.get_Range(Osheet.Cells[1, 1], Osheet.Cells[dataGridView1.RowCount, dataGridView1.ColumnCount]);
                oRng.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                          
                // app.Visible = false;
                app.UserControl = false;
                // Need all following code to clean up and remove all references!!!
                Wb.Close(null, null, null);
                app.Workbooks.Close();
                app.Quit();
            }

            catch (Exception theException)
            {
                //MessageBox.Show(theException.Message);
            }
        }

Friday, August 5, 2011

Message Box Control

Open a Form of one project from another project

 Look into this Link: http://www.dreamincode.net/forums/topic/78164-open-project-from-another-one-in-visual-c%23/

i.e,

1) create a new project
2) Right click on solution and add existing project (select project from which you want to access form)
3) Add these codes in new project:


ExistingProjectName.Form1 sForm1 = New ExistingProjectName.Form1();
sForm1.show();

How to focus a cell in Datagrid


This is the way:       dataGridView1.CurrentCell = dataGridView1[column, row];

Add DateTimePicker as a column in a DataGrid


Look into this Site: http://msdn.microsoft.com/en-us/library/7tas5c80.aspx