Search This Blog

Friday, January 4, 2013

Print RadGridView Telerik Windows Forms (VB.NET)

Telerik > Windows Forms > Print RadGridView

RadPrintDocument
Defines a reusable object that sends output to a printer and manages the whole printing process, when printing from an application

PrintPreviewDialog
Represents a dialog box form that contains a PrintPreviewControl for printing from a Windows Forms application.

AssociatedObject
 Gets or sets the object, associated with this document.

Print directly

Example:

Dim dialog As New PrintPreviewDialog
Dim RadPrintDocument1 As New RadPrintDocument
RadPrintDocument1.AssociatedObject = Me.RadGridView1
RadPrintDocument1.MiddleHeader = lblTitle.Text
RadPrintDocument1.MiddleFooter = "Page [Page #] of [Total Pages]"
RadPrintDocument1.RightFooter = "[Date Printed]"
dialog.Document = RadPrintDocument1
dialog.StartPosition = FormStartPosition.CenterScreen
dialog.ShowDialog()





Friday, December 28, 2012

Key events not fired Windows Forms

C# > Form > KeyPreview 

KeyPreview gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.






Example

Key events not fired Windows Forms

Solution:

Set KeyPreview property to True


Thursday, December 27, 2012

double (C#)

C# > Types > Double






Double type stores 64-bit floating-point values.

range: ±5.0 × 10−324 to ±1.7 × 10308
precision: 15-16 digits

By default, a real numeric literal on the right side of the assignment operator is treated as double, but if you want an integer number to be treated as double, use the suffix d or D.

double x = 10D;


Integral types and floating-point types can be mixed in an expression:

  • If one type is double the expression evaluates to double
  • If no double type in the expression it evaluates to float
Example: the sum is double type


int x = 1;
float y = 2.5f;
double w = 1.2E+1;
MessageBox.Show ("The sum is: " + (x + y +  w).ToString());
 


 
 


Common Language Specification (CLS)

Common Language Specification is a set of base rules to which any language targeting the CLI should conform in order to interoperate with other CLS-compliant languages.

Common Language Specification (CLS) is a set of basic language features needed by many applications.

To fully interact with other objects regardless of the language they were implemented in, objects must expose to callers only those features that are common to all the languages they must interoperate with.

UInt32 Structure

UInt32 Structure represents a 32-bit unsigned integer.

The UInt32 type is not CLS-compliant.
The CLS-compliant alternative type is Int64.

HttpContext.Session ASP.NET

ASP.NET > HttpContext > Session

Gets the HttpSessionState object for the current HTTP request.

ASP.NET pages contain a default reference to the System.Web namespace you can reference the members of HttpContext on an .aspx page without the fully qualified class reference to HttpContext. For example, you can use just Session("USER").

Note: If you want to use the members of HttpResponse from an ASP.NET code-behind module, you must include a reference to the System.Web and also fully qualify the reference.

For example, in a code-behind page you must specify the full name:
 
HttpContext.Current.Session("USER").







Friday, December 21, 2012

Class with events VB NET

VB.NET > Class > WithEvents

WithEvents specifies that one or more declared member variables refer to an instance of a class that can raise events.

Example: class with events

 Public Class Export
        Public Event TimesUp()
        Public Sub New()
            Dim worker As New BackgroundWorker()
            AddHandler worker.DoWork, AddressOf DoWork
            AddHandler worker.RunWorkerCompleted, AddressOf bg_RunWorkerCompleted
            worker.RunWorkerAsync()
        End Sub
        Private Sub DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
            ' export stuff
            Thread.Sleep(5000)
        End Sub
        Private Sub bg_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
            MsgBox("Background worker completed", vbInformation, "Background worker")
            RaiseEvent TimesUp() 'Triggers an event declared at module level within a class, form, or document.
        End Sub
    End Class

    Dim WithEvents _Export As New Export
    Private Sub handleTimesUp() Handles _Export.TimesUp
        MsgBox("TimesUp Event Raised and Handled")
    End Sub