We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to set default datetime to current datetime in GridDateTimeColumn ?

Hello,
I have the following questions about GridDateTimeColumn :
1) How to change the default datetime in cell of the GridDateTimeColumn ?
2) I can select only date by clicking on combobox datetime in cell. How to select date and time in the same cell ?
Regards. 

3 Replies

GG Gowtham Gopalsamy Syncfusion Team August 26, 2019 12:40 PM UTC

Hi Cosyspro,   
  
Thanks for your patience.   


 
 
S.No   
Query   
Response   
1   
How to change the default datetime in cell of the GridDateTimeColumn ?   
You can achieve your requirement to change the default datetime by using theFormat property in GridDateTimeColumn.   
  
Please refer the below code snippet.  
    
this.sfDataGrid1.Columns.Add(new GridDateTimeColumn() { MappingName ="OrderDate", HeaderText = "Order Date", Format = "MM/dd/yyyy" });   
   
     
Please refer to the following sample link,     
   
Please refer to the following UG link,     
2   
I can select only date by clicking on combobox datetime in cell. How to select date and time in the same cell ?   
We are analyzing your requirement to choose the date and time in GridDateTimeColumn. We will update more details with 28th August,2019. 
  
  
Please let us know if you require further assistance on this.  
 
Regards, 
Gowtham 



CO Cosyspro August 27, 2019 01:32 PM UTC

Hi Gowtham,
Thanks for your reply.
I give more details about my previous question. When I click on datetime cell in the new row, the cell displays 01/01/0001 as default date. How to set the default datetime to date of today?
Regards 


SS Susmitha Sundar Syncfusion Team August 28, 2019 01:59 PM UTC

Hi Cosyspro, 
 
Thank you for your patience. 
 
Please find the details for your queries, 
 
Query 
Detail 
I can select only date by clicking on combobox datetime in cell. How to select date and time in the same cell ?   
We have considered your requirement of “Edit the time value by SfDateTimeEdit DropDown popup” in WinForms and logged feature request for the same. We will implement this feature in any of our upcoming release.  
 
We appreciate your patience until then. 
 
You can also communicate with us regarding the open features any time using our Feature Report page.  
  
Feedback link
  
If you have any more specification/suggestions to the feature request, you can add it as a comment in the portal and cast your vote to make it count. 
 
When I click on datetime cell in the new row, the cell displays 01/01/0001 as default date. How to set the default datetime to date of today? 
Your requirement can be achieved by AddNewRowInitiating event. Please refer the below code snippet, 
C#: 
this.sfDataGrid1.AddNewRowInitiating += SfDataGrid1_AddNewRowInitiating; 
 
private void SfDataGrid1_AddNewRowInitiating(object sender, AddNewRowInitiatingEventArgs e) 
        { 
            var data = e.NewObject as OrderInfo; 
            data.OrderDate = DateTime.Now; 
        } 
 
 
 
Please contact us if you need further assistance. 
 
Regards, 
Susmitha S 


Loader.
Live Chat Icon For mobile
Up arrow icon