Print Page | Close Window

Mask for DateTime field in PropertyGrid

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=13352
Printed Date: 30 November 2024 at 3:50pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Mask for DateTime field in PropertyGrid
Posted By: p4kumar
Subject: Mask for DateTime field in PropertyGrid
Date Posted: 06 February 2009 at 11:11am
All,

How can I create a mask to the DateTime field in the propertygrid such a way that, user can enter only in that format. For example, by default "dd/mm/yyyy" should be displayed in the DateTime field. When user key in numbers, the numbers should replace the respective palces in the field. Ofcourse, user can give input from DateTime picker also.

Please, suggest me by giving code snippets or sample source code. Thanks in advance.



Replies:
Posted By: Aaron
Date Posted: 15 February 2009 at 6:06am
Hi,
 
Here's is code from samples
 
Dim DateItem As PropertyGridItemDate
   
    'Adds a date item with an initial date of 14/02/2009
    Set DateItem = Category.AddChildItem(PropertyItemDate, "DateItem", "14/02/2009")
   
    'Sets date format to MM/DD/YYYY
    DateItem.Format = "%d/%m/%Y"
   
    'Returns the currently set date formated with the mask MM/DD/YYYY
    Debug.Print "Currently set date (DD/MM/YYYY): " & DateItem.Value
   
    'Returns the currently set date without a format mask
    Debug.Print "Unformated date (DDMMYYYY): " & DateItem.MaskedText
    'Changes Day to the 13th
    DateItem.Day = 13
    
    'Changes Month to February
    DateItem.Month = 2
   
    'Changes the Year to 2009
    DateItem.Year = 2009
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: p4kumar
Date Posted: 19 February 2009 at 11:17pm
Hi Aaron,

Thank you very much for your reply. But, Im working on C#, .NET and it is little bit difficult to understand as I have used Visual Basics long back. Can you please explain this in C# and .NET?

It would be greatful if you share any source code with me. Thank you.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net