Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > how to set default value for a textbox?
 

how to set default value for a textbox?

In microsoft access, there is a property to set default value.

Is there any way to set the default value for the textbox in vb 2005 to set current date for the default (if not use datetimepicker), so when a row is added, the value for a field is today().

yandi  Tuesday, May 30, 2006 4:17 AM

Hi,

You can try this:

Dim dt As DateTime

dt = DateTime.Today

Me.TextBox1.Text = dt.ToShortDateString()

Hope that helps.

Regards,

Mamta

Mamta M  Tuesday, May 30, 2006 8:15 AM

Hello,

if your textbox is bound: before you add the new row you must set the default value of the column to which the textbox is bound to 'Now'

if your textbox is not bound: when you need it you manually set the 'Text' property of the textbox to 'Now'.

HTH

Stefano

  • Proposed As Answer byK.MAK Thursday, September 03, 2009 11:15 PM
  •  
Stefano Padovan  Tuesday, May 30, 2006 9:04 AM

Hello,

if your textbox is bound: before you add the new row you must set the default value of the column to which the textbox is bound to 'Now'

if your textbox is not bound: when you need it you manually set the 'Text' property of the textbox to 'Now'.

HTH

Stefano


Note: you can use DateTime.Now.Today
K.MAK  Thursday, September 03, 2009 11:16 PM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView - Items Not Displayed - BindingSource.Count Not Equal To DataSource.Count
• Accessing data through internet
• DataGridView cell focus and paste data problem
• How to copy/create TableAdapter commands
• Custom Background
• BindingNavigator updateproblems
• Problem inheriting DataGridView
• SQLException
• DataGridViewComboBoxColumn Selecting on Tab
• find column index of a column in Datagridview