Click here to Skip to main content
15,914,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am trying to format a textbox which got data from bindingsource

txtReportDate.DataBindings.Add("Text", dvHistory, "Start Date")

I need to display the txtReportDate as a "dd/mm/yy" date. Any Ideas?

Thanks in advance
Posted
Comments
Member 13635520 9-Mar-23 16:56pm    
I have Same Issue but this solution does not work for me, Please help

businessPeriodStartDateEdit.DataBindings.Add(new Binding("Text", bs, "BusinessPeriodStartDate"));

You can change the default for the culture:

using System; 
using System.Globalization; 
using System.Threading;  
namespace test 
{     
  public static class Program 
  {         
    public static void Main() 
    {             
      CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
      culture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy"; 
      culture.DateTimeFormat.LongTimePattern = "";  
      Thread.CurrentThread.CurrentCulture = culture;
      Console.WriteLine(DateTime.Now);
    }
  } 
} 
 
Share this answer
 
thanks for reply guys :)
finally I found the solution
txtReportDate.DataBindings.Add("Text", dvHistory, "Start Date",true,databaseupdatemode.never,"","dd-MMM-yyyy")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900