blinking cursor on custom control in c sharp .net

Hi Experts,

I'd like to create my own edit control which shows the date in the form YYYY-MM-DD.  This control will validate the date if it's specified in its entirety, but it will also allow the user to only specify the year or just the year and month if they want.

My question is, I could subclass the edit control directly, but if I was creating my own UserControl, then how would I show a blinking cursor?  (how do they do it in the actual edit control)?  Do they create a thread to set paint events to draw it and then remove it - or a timer?

Any suggestions on creating this control would be appreciated.

Thanks,
Mike
LVL 1
threadyAsked:
Who is Participating?
 
pivarCommented:
In that case you have to implement your own OnPaint for your TextBox. The RicheditBox would allow you to have different fonts, colors etc, but may in this case be awkward to work with.
0
 
pivarCommented:
Hi,

The blinking cursor is called a caret and you can create it via Win32 API. Haven't tried it myself though. Here's a link to p/invoke http://www.pinvoke.net/default.aspx/user32/CreateCaret.html.
Although I think it must be easier to use a textbox and validate the input according to your rules.

/peter
0
 
threadyAuthor Commented:
Hi Peter,

Thanks for your response.  If I go for the textbox with the validating input, is there a way to do something like Facebook's login (where they place a grayed out 'login' in the login textbox and a grayed out 'password' in the password box)?

i.e., is there a way to have 2 fonts at a time in the textbox so that I can display YYYY-MM-DD grayed and type as much of the date as I need (leaving the grayed background there as long as I don't type more and more of the date?

Thanks,
Mike
0
 
threadyAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.