Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: datetimepicker format for entire application!! Pin
Luc Pattyn27-Dec-09 2:03
sitebuilderLuc Pattyn27-Dec-09 2:03 
GeneralRe: datetimepicker format for entire application!! Pin
Hussam Fattahi27-Dec-09 20:02
Hussam Fattahi27-Dec-09 20:02 
GeneralRe: datetimepicker format for entire application!! Pin
#realJSOP27-Dec-09 23:58
mve#realJSOP27-Dec-09 23:58 
GeneralRe: datetimepicker format for entire application!! Pin
Hussam Fattahi28-Dec-09 2:14
Hussam Fattahi28-Dec-09 2:14 
GeneralRe: datetimepicker format for entire application!! Pin
#realJSOP28-Dec-09 4:38
mve#realJSOP28-Dec-09 4:38 
GeneralRe: datetimepicker format for entire application!! Pin
ProtoBytes28-Dec-09 12:22
ProtoBytes28-Dec-09 12:22 
GeneralRe: datetimepicker format for entire application!! Pin
Hussam Fattahi28-Dec-09 22:23
Hussam Fattahi28-Dec-09 22:23 
GeneralRe: datetimepicker format for entire application!! [Extension Method] Pin
ProtoBytes29-Dec-09 3:14
ProtoBytes29-Dec-09 3:14 
Well, an extension method is a new method declaration in 3.5 and above. Think of it as sort of a helper method and overload at the same time.

From MSDN:

'Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For client code written in C# and Visual Basic, there is no apparent difference between calling an extension method and the methods that are actually defined in a type.'

Example:

namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static int WordCount(this String str)
        {
            return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length;
        }
    }   
}


In this example the extension method is WordCount which returns an int, and can be called using the construct:

String myString = "Hello World";
int count = myString.WordCount();


If you look at the string class you won't find a 'WordCount' method, it has been made a 'custom extension' of the string class.

So for your date picker you could create extension methods and customize the class how ever you would like with out inheritance etc.

Some good Extension Method Resources:

Extension Methods (C# Programming Guide)[^]

C# .NET Extension Methods 3.0[^]

I have run into this problem with the DateTimePicker and used this type of solution to solve the problem.

additionally if you do use an extension method for the DateTimePicker you can name it so the code reflects the fact that you have made a specialization to the date time returned. Ie. DateTimePicker.MyDateTime();

I think Luc has an article on this geared for the DateTime class.
~TheArch
GeneralRe: datetimepicker format for entire application!! [Extension Method] Pin
elizas7-Jun-10 1:24
elizas7-Jun-10 1:24 
Questionprinting capability Pin
Ryan Minor26-Dec-09 19:55
Ryan Minor26-Dec-09 19:55 
AnswerRe: printing capability Pin
dan!sh 26-Dec-09 20:12
professional dan!sh 26-Dec-09 20:12 
GeneralRe: printing capability Pin
Ben Fair28-Dec-09 10:24
Ben Fair28-Dec-09 10:24 
AnswerRe: printing capability Pin
MumbleB26-Dec-09 20:47
MumbleB26-Dec-09 20:47 
AnswerRe: printing capability Pin
Ravi Bhavnani27-Dec-09 20:52
professionalRavi Bhavnani27-Dec-09 20:52 
QuestionDate Time Format Pin
Abdullah Al-Muzahid26-Dec-09 17:26
professionalAbdullah Al-Muzahid26-Dec-09 17:26 
AnswerRe: Date Time Format Pin
dan!sh 26-Dec-09 18:06
professional dan!sh 26-Dec-09 18:06 
GeneralRe: Date Time Format Pin
Abdullah Al-Muzahid26-Dec-09 21:51
professionalAbdullah Al-Muzahid26-Dec-09 21:51 
GeneralRe: Date Time Format Pin
dan!sh 26-Dec-09 22:56
professional dan!sh 26-Dec-09 22:56 
GeneralRe: Date Time Format Pin
Abdullah Al-Muzahid26-Dec-09 23:50
professionalAbdullah Al-Muzahid26-Dec-09 23:50 
GeneralRe: Date Time Format Pin
dan!sh 27-Dec-09 0:21
professional dan!sh 27-Dec-09 0:21 
Question[Message Deleted] Pin
ikurtz26-Dec-09 10:13
ikurtz26-Dec-09 10:13 
Questionuse a Datagridviwcomboboxcell in a binded datagridview Pin
baranils26-Dec-09 8:04
baranils26-Dec-09 8:04 
AnswerRe: use a Datagridviwcomboboxcell in a binded datagridview Pin
dan!sh 26-Dec-09 18:08
professional dan!sh 26-Dec-09 18:08 
GeneralRe: use a Datagridviwcomboboxcell in a binded datagridview Pin
baranils26-Dec-09 22:23
baranils26-Dec-09 22:23 
GeneralRe: use a Datagridviwcomboboxcell in a binded datagridview Pin
dan!sh 26-Dec-09 23:07
professional dan!sh 26-Dec-09 23:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.