change textbox to datetimepicker

  • Thread starter Thread starter Darin
  • Start date Start date
D

Darin

Is there a way to, at runtime, change a textbox to be a datetimepicker?

I have a form that I allow the user to specify what field types the
input boxes are. They can be regular text, integer, money, date, or
date&time. So, I have the textbox and when I see that this field is a
date, I want to change the textbox to a datetimepicker. Can that be done
at runtime?

TIA

Darin
 
Darin,

Just hide the textbox and show the DateTimePicker in its place when the user
makes a request to enter a date.

Dan
 
I have done that before, I just don't want to now. This for has 10
textboxes, user definable to text, int, money, date, date&time. I have
my own controls for int text box and money text box, so, using your
solution, I would have to create 10 text boxes, 10 integer boxes, 10
money boxes, and 10 datetimepicker, then hide the one I don't need. That
seems like an awful lot of overhead.

I guess I could build each box at runtime for that specific type - I
will work on that.

Darin
 
Darin,

you could always instantiate the control when you need it and then dispose
of it when you don't

Dim dtctl as New DateTimePicker

MyForm.Controls.Add(dtctl)

' and when the user requests a new type of control

MyForm.Controls.Remove(dtctl)
dtctl = Nothing

' now show the new control
 
Back
Top