Search This Blog

Thursday, January 10, 2013

First and Last day of a Month VB .NET

VB.NET > Functions > > DateSerial

Returns a Date value representing a specified year, month, and day, with the time information set to midnight (00:00:00).

Examples


First and last day of a month

VB.net
' first day of month
FirstDay = DateSerial(Today.Year, Today.Month, 1)
' month's last day
LastDay = DateSerial(Today.Year, Today.Month , 0)

C#

DateTime firstDayOfTheMonth = new DateTime(DateTime.Today.Year,DateTime.Today.Month, 1);
DateTime lastDayOfTheMonth = firstDayOfTheMonth.AddMonths(1).AddDays(-1);






Tuesday, January 8, 2013

Add Rows to RadGridView WinForms VB.NET

Telerik > RadGridView > Rows

GridViewRowInfo is the logical representation of a single row.

Examples

1. Add rows

You can add rows by creating an instance of GridViewDataRowInfo and adding it to the Rows collection of RadGridView

Dim rowInfo As New GridViewDataRowInfo(Me.RadGridView1.MasterView)
rowInfo.Cells(0).Value = "new row"
RadGridView1.Rows.Add(rowInfo)





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.