Contains print services for Windows Forms applications.
Search This Blog
Thursday, April 24, 2014
Gets the default printer C#
C# > Printing > PrinterSettings > IsDefaultPrinter
Gets the default printer.
Example
Gets the default printer.
Example
PrintDocument printDoc = new PrintDocument();
if (printDoc.PrinterSettings.IsDefaultPrinter)
{
MessageBox.Show (printDoc.PrinterSettings.PrinterName);
}
Etichete:
c#
Friday, April 11, 2014
Get all printers installed on computer C#
C# > Printing > PrinterSettings > InstalledPrinters
Contains the names of all printers installed on the computer.
Example: Get all printers installed on computer
Contains the names of all printers installed on the computer.
Example: Get all printers installed on computer
foreach (string prt in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
MessageBox.Show(prt);
}
Etichete:
c#
Wednesday, April 9, 2014
DateTime Compare C# Example
C# > System Namespace > DateTime > Compare
Compares two dates of type DateTime.
Example
Compares two dates of type DateTime.
Example
DateTime date1 = new DateTime(2014, 4, 1, 0, 0, 0);
DateTime date2 = new DateTime(2014, 5, 1, 0, 0, 0);
int cmp = DateTime.Compare(date1, date2);
if (cmp < 0)
MessageBox.Show("date1 is earlier than date2");
else if (cmp == 0)
MessageBox.Show("date1 is equal to date2");
else
MessageBox.Show("date1 is later than date2");
Etichete:
c#
Tuesday, April 8, 2014
Check if a date is weekend day C#
C# > System Namespace > DateTime > DayOfWeek
The DayOfWeek enumeration represents the day of the week.
Its value ranges from zero (DayOfWeek.Sunday) to six (DayOfWeek.Saturday).
Example: Check if a date is weekend day
The DayOfWeek enumeration represents the day of the week.
Its value ranges from zero (DayOfWeek.Sunday) to six (DayOfWeek.Saturday).
Example: Check if a date is weekend day
DateTime date1 = DateTime.Now;
if ((date1.DayOfWeek == DayOfWeek.Saturday || date1.DayOfWeek == DayOfWeek.Sunday ))
{
// action
}
Etichete:
c#
DateTime Structure C#
C# > System Namespace > DateTime
DateTime structure represents an instant in time.
Example
DateTime structure represents an instant in time.
- Days in month
- Add methods
- Nullable
- First & Last day of the month
- DayOfWeek
- Compare
- Convert string to date
Example
DateTime dt= DateTime.Now;
Etichete:
c#
Days In Month C# Example
C# > System Namespace > DateTime > DaysInMonth
Returns the number of days in the specified year and month.
Example
Returns the number of days in the specified year and month.
Example
int daysInMonth = System.DateTime.DaysInMonth(2014, 4);
Etichete:
c#
Subscribe to:
Posts (Atom)