Search This Blog

Monday, May 30, 2011

Some tips - Placing bookmarks in VS

Many a times we find ourselves in a situation where we need to scroll up and down a page and in between we get lost... To make our lives simpler we have bookmarks in Visual Studio Environment.

We can place bookmarks on the lines where we would like to re-visit, delete them, delete all of them, jump to next or previous bookmarks within same page or within the whole solution. Visual Studio also provides a toolbar so that it can be done just in one click.


1) To place a bookmark or to remove a bookmark.
2) To navigate to previous bookmark (within the solution)
3) To navigate to next bookmark (within the solution)
4) To navigate to previous bookmark (within the folder)
5) To navigate to next bookmark (within the folder)
6) To navigate to previous bookmark (within the page)
7) To navigate to next bookmark (within the page)
8) To delete all bookmarks.

Their are also keyboard shortcuts available :-
1) To place a bookmark or to remove a bookmark  Ctrl + B, T
2) To navigate to previous bookmark (within the solution)  Ctrl + B, P
3) To navigate to next bookmark (within the solution)  Ctrl + B, N
4) To delete all bookmarks.  Ctrl + B, C

Cheers!

Tuesday, September 28, 2010

Writing into an excel file

You need to add reference to  Com component - Microsoft.excel.

Excel.ApplicationClass app = new Excel.ApplicationClass();

Excel.Workbook wk = app.Workbooks.Open("F:\\MyExcel.xls", 0, false, 5,"", "", true, Excel.XlPlatform.xlWindows, "\t", true, false,0, true,true,false);

Excel.Sheets sheets = wk.Worksheets;

Excel.Worksheet sheet1 = (Excel.Worksheet)sheets.get_Item(1);

try{
for (int i = 1; i <= dtEmployee.Rows.Count; i++)  //dtEmployee is a datatable containing data
{
        for (int j = 1; j <= dtEmployee.Columns.Count; j++)
         {
                sheet1.Cells[i, j] = dtEmployee.Rows[i-1][j-1];
          }
}
}

catch{
}

finally{

app.Workbooks.Close();
app.Quit();
}

Data overriding vs data hiding

Data overriding is when u want to override a method of base class in your derived class. In this whenever you create an object and call the method derived class method will be called , irrespective of what you are using on left hand side (base class name or derived class name). ie




In both these cases the method Calc of derived class will be called, or you can say derived class method will always override base class method. And the result would be

Data Hiding
In data hiding, you hide the base class method, and define a new method. Now the new method )in derived class) will be called only if the object is of derived class type (on left hand side also).
The output is,
Result: 28.26
Reult: 12
Result: 28.26
Result: 7