How can you set minimum date in code for the cxDateEdit so user can not select date less than the one I specified ? I could do it in property but code is more applicable.
Asked
Active
Viewed 875 times
-2
-
2So set the property in code. What exactly is the question? – Ken White Apr 14 '13 at 23:56
-
@Ken I guess the confusion is that the property is somewhat buried. Probably easy to find in the OI. – David Heffernan Apr 15 '13 at 00:04
-
@David: From the answer you posted (to a non-question), it doesn't seem that complicated. Some minimal effort should be spent figuring it out yourself. If you see it in the OI under an entry named `Properties`, it seems to me you could type in your code `cxDateEdit.Properties.` and see what happens, and figure this out pretty easily. – Ken White Apr 15 '13 at 00:07
-
@Ken Yes it does seem pretty simple. Perhaps I missed the point. I just did a websearch, don't have devexpress myself. Maybe the OI presents it differently. I kind of wonder what the Properies object is for. Why the extra layer? – David Heffernan Apr 15 '13 at 00:10
-
@David: I don't have them either. It does seem, though, that if you (as a non-user of the components) could find an answer that quickly through a search, the asker could have found one in the documentation (or source code) even more quickly. – Ken White Apr 15 '13 at 00:12
1 Answers
1
Like this:
cxDateEdit.Properties.MinDate := EncodeDate(2013, 4, 1);

David Heffernan
- 601,492
- 42
- 1,072
- 1,490
-
whats the second part ? If I set the date I get : [dcc32 Error] Unit1.pas(42): E2018 Record, object or class type required. If I '' , I get : [dcc32 Error] Unit1.pas(42): E2010 Incompatible types: 'TDateTime' and 'string' – user763539 Apr 15 '13 at 00:26
-
You'll need to put a date time variable in there. Is that what the question is about? You want to know how to make a date time variable? What date do you want? – David Heffernan Apr 15 '13 at 00:32
-
01.4.2013 :) If possible ... Just learning these components .... never used them before ... – user763539 Apr 15 '13 at 00:34
-
-
Where is the nice to put this code ? On onchange of the cxDateedit or somewhere else ? – user763539 Apr 15 '13 at 00:43
-
I don't know. You tell me. OnChange sounds no good. Too late then. Form initialisation sounds more likely. Only you know the logic. – David Heffernan Apr 15 '13 at 00:49
-
Actually, what I had in mind was preventing the user from scrolling (or selecting) the date lower than the one I have set by blocking the choice. This way user can still select lower dates but with warning. But ok...I can adapt this ...Thank you ! – user763539 Apr 15 '13 at 00:54
-
I thought thats what the OI is for. Of course you can apply constraints like this in the code, especially when the e.g. min date is dynamic. I think the `FormCreate` event is a good place to initialize components. – alzaimar Apr 15 '13 at 05:58