January 2010

You are currently browsing the articles from Information City written in the month of January 2010.

Visual Studio: Expand or Collapse Region or Code section

Been using it for a while and started to love the function. One colleague of mine asked me how I did it. Thought it would be worth a post over here:

Using Shortcut keys
Ctrl-M, Ctrl-O will collapse all of the code to its definitions.
Ctrl-M, Ctrl-L will expand all of the code (actually, this one toggles it).
Ctrl-M, Ctrl-M will expand or collapse a single region

P/S: The menus for expanding and collapsing code can also be found under Edit->Outlining

Written by admin on January 22nd, 2010 with no comments.
Read more articles on Knowledge Base and Personal and Programming.

Programming: Crystal report custom papersize printout

Was facing some problem in printing the custom paper sized crystal report which is meant for label. During development, the report shown correctly and perfectly nice. However, upon implementing to client’s server, the report is loaded onto a different sized paper (other than the customized one). A little research here and there with trial and testing, manage to get the crystal report working. An additional codes is required and below is the functional code:

Private Sub reportPrinterSEtup()
Dim doctoprint As New System.Drawing.Printing.PrintDocument()
doctoprint.PrinterSettings.PrinterName = “Microsoft XPS Document Writer” ‘(ex. “Epson SQ-1170 ESC/P 2″)
For i = 0 To doctoprint.PrinterSettings.PaperSizes.Count – 1
Dim rawKind As Integer
If UCase(doctoprint.PrinterSettings.PaperSizes(i).PaperName) = ucase(“LABEL”) Then
rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(i).GetType().GetField(“kind”, Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(i)))
crReportDocument.PrintOptions.PaperSize = rawKind
Exit For
End If
Next
End Sub

The doctoprint.PrinterSettings.PrinterName requires a valid printer name which exist in the hosting site. I’ve used “Microsoft XPS Document Writer” as it seems to be bundled together with Windows. The “LABEL” value will have to change to the name of custom papersize created. Note that the values are case sensitive.

Written by admin on January 21st, 2010 with no comments.
Read more articles on Knowledge Base and Programming.

« Older articles

Newer articles »