473,666 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change textbox to datetimepicker

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
3 4880
Darin,

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

Dan

"Darin" <darin_nospam@n ospamever> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
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
"Darin" <darin_nospam@n ospamever> wrote in message
news:u9******** ******@TK2MSFTN GP10.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1237
by: Bhavna | last post by:
I have a datetimepicker (dtp) on my windows form the user initially selects a date and then selects the rooms they wish to book The problem i have is that when the user goes back and tries to change the date (i.e when they click on the dtp), i show a message box that states that changing the date will cause all the current bookings to be lost. Do u wish to continue? If the user selects yes all the datatables are cleared and the date is changed...
1
1447
by: CYShao | last post by:
How to change the BGcolor of DateTimePicker ? I fialed to find any attributes of this, but only found BGcolor of calendar. How can I change the BGcolor of DateTimePicker window? Thanks CYShao
2
3862
by: Richard | last post by:
Hi, I have a DateTime picker control on a form. The datetime picker control is data bound to a column in a DataTable. Yes I know about bound DateTime pickers and DBNull and etc. so no troubles with that stuff... However, as somebody out there probably knows, programmatically setting the DateTimePicker.Value property to a new VALUE does NOT in itself constitute a CHANGE to
5
9587
by: christian ternek | last post by:
Hello ! I want to make a custom textbox and inherit a custom control from textbox. Now i want to change the looking of the textbox with the following code: protected override void OnPaint(PaintEventArgs e) {
1
9401
by: Rich | last post by:
Hello, I have some datefields in a dataset (ds1). I bind some textbox controls on a windows form to these date fields in ds1, but I only want to see 01/01/2004 instead of 1/1/2004 8:00:00 AM. In a DateTimePicker control I can set a custom format("MM/dd/yyyy"). So when I iterate through ds1 with currency manager (cma) I see the correct date format in a DateTimePicker control. Is it possible to set a custom date format like that for...
13
6933
by: Stefan | last post by:
hello, Just a sort of newbie question. How can i change the backcolor of the controls which have the focus (textbox/combobox/datetimepicker) and set it back to white when they lost focus. thanx in advance Stefan
2
1285
by: Art | last post by:
Hi, I'm still somewhat new to OO. I am creating a class for a TextBox because I need some specific things for it to do. That is, I'm inheriting a TextBox and putting in some properties, etc. that I need for it. Now I find I need to do something similar with a DateTimePicker. Many of the things I have to add are the same. It seems to me that there's probably an OO way to handle this so that I don't have to re-type all of the stuff I...
0
2199
by: morathm | last post by:
I have a windows client database management application written in C# that connects to remote web services to do all the heavy work. The thin-client app uses strong typed datasets, all maintained at the web service, with a web reference to those datasets via exposed s on the web service. The client app has a series of windows forms designed to manage particular types of data. For example, there's a manage users form. On each of these...
4
2669
by: fts2012 | last post by:
' if the textbox is empty show an error message 1001 Private Sub TextBox1_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating TextBox1.BackColor = Color.White If TextBox1.Text.Length = 0 Then TextBox1.Select() TextBox1.BackColor = Color.Yellow MsgBox("1001") e.Cancel = True
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.