By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,149 Members | 885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,149 IT Pros & Developers. It's quick & easy.

Custome control from DateTime format string

P: n/a
I've got a custom control that is trying to allow the user to enter a
DateTime in a definable format and I was wondering if there was an
easy way to alter the look of said control based on the contents of
the format string. For example I would like a year TextBox that is
small if input formatting string contains "yy" and larger if it
contains "yyyy".
I guess I could write a parser with string.Contains et. al. but that
seems fairly kludgy, any ideas?

Feb 8 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
For dates isnt there a calender (graphical) to use...
Feb 8 '08 #2

P: n/a
gr****@gmail.com skrev:
I've got a custom control that is trying to allow the user to enter a
DateTime in a definable format and I was wondering if there was an
easy way to alter the look of said control based on the contents of
the format string. For example I would like a year TextBox that is
small if input formatting string contains "yy" and larger if it
contains "yyyy".
I guess I could write a parser with string.Contains et. al. but that
seems fairly kludgy, any ideas?
Use DateTimePicker dtp; with dtp.Format=DateTimePickerFormat.Custom, and
dtp.CustomFormat="yy.MM.dd HH:mm" for example.

Believe me, you will never be able to trap all variants a user might try
to use in a TextBox.

Use dtp.Value.ToString("yy.MM.dd HH:mm") to get out whatever format you
want.

--
Bjørn Brox
Feb 8 '08 #3

P: n/a
Hi,

You need to give more details, is this a web or a win app?
Where you got your control from?
Do you have the source code (you are talking about modifying it after all)
<gr****@gmail.comwrote in message
news:3c**********************************@e10g2000 prf.googlegroups.com...
I've got a custom control that is trying to allow the user to enter a
DateTime in a definable format and I was wondering if there was an
easy way to alter the look of said control based on the contents of
the format string. For example I would like a year TextBox that is
small if input formatting string contains "yy" and larger if it
contains "yyyy".
I guess I could write a parser with string.Contains et. al. but that
seems fairly kludgy, any ideas?
Feb 10 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.