This is a migrated thread and some comments may be shown as answers.

DateTime Format Copy Select Value ALL DIFFERENT

8 Answers 202 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Abba
Top achievements
Rank 1
Abba asked on 23 Sep 2016, 10:53 PM

I have a grid with a datetime column that gets populated.
I format the date yyyy-mm-dd 12 hr. (yyyy-MM-dd hh:mm:ss.fff tt).  For example: 2016-05-12 02:38:25.613 PM

For Each column As GridViewColumn In GridView.Columns
            If TypeOf column Is GridViewDateTimeColumn Then
                'change the formatting
                Dim col As GridViewDateTimeColumn = TryCast(column, GridViewDateTimeColumn)
                col.FormatString = "{0: yyyy-MM-dd hh:mm:ss.fff tt}"

                'set the tooltip on the column

            End If
        Next

 

Now, when i select the value, the actual value is not my formatted, but instead: mm/dd/yyyy.  For example: 5/12/2016 2:38:25 PM
If I copy the cell and paste in notepad it shows yyyy-mm-dd 24 hr with only hr/minute, no seconds.  For example: 2016-05-12 14:38

 

Can anyone explain this RETARDATION??

 

Sorry to sound like a jerk, but it is quite frustrating when simple things like this are not correct.  This control has been out for 8-10 years now.  Why would it not ALL match the SAME value that is displayed??  IMAGINE THAT!

It is also irritating to have to spend time finding and bringing this up and expected to pay support thousands each year for things that are correct and function normal by now.  No excuse for this.  

 

...I have a feeling I will not be getting a response, like my MANY other threads that go unanswered here.

Please build better controls that work as intended and not need constant workarounds as well as have lingering issues (performance) that never seem to get resolved.

 

8 Answers, 1 is accepted

Sort by
0
Abba
Top achievements
Rank 1
answered on 23 Sep 2016, 10:57 PM

By the way,

A lot of time is spent fighting your control's issues to make them work the way they should (the way MOST users use and need them).  That time should be used to develop, not come up with workaround and hacks and more (undocumented) solutions.

0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 27 Sep 2016, 05:59 AM

I can confirm this behavior (2016R3). Strangely enough, it happens only when I select and copy the cell only.

When copying the whole row, the date is formatted as expected.

I suggest that you open a support ticket.

Regards

Erwin

0
Hristo
Telerik team
answered on 27 Sep 2016, 01:30 PM
Hello guys,

Thank you for writing.

The observed behavior is incorrect and we consider it an issue. I have logged it in our feedback portal and I have also added a vote for it on your behalves. Abba`s Telerik Points are updated for submitting the report. You can additionally subscribe to the item and be updated with all of its status changes: FIX. RadGridView - when copied the date values should respect the format string property set on the GridViewDateTimeColumn

Please use the suggested in the feedback item workaround solution until we permanently resolve the issue.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Abba
Top achievements
Rank 1
answered on 28 Sep 2016, 05:23 AM
Hi guys,

Again, thanks for looking into this quickly, and sorry for the harsh words.

So, the problem was with 3 formats, all different:  
So the visible one is correct.  
The copy (as you confirmed) is not.  
But what about the actual underlying value?  Meaning, if I click on a cell and access the cell value to string and put that value in a textbox it is in a different format completely.  More to the original.  Is there a way to get this the same?  Is it a matter of setting something else (meaning one for display vs actual)?  Will this fix/workaround you provided resolve it as well?

Thanks for the workaround I will try it and let you know.

0
Abba
Top achievements
Rank 1
answered on 28 Sep 2016, 05:28 AM
And by the way, this is probably more important (that the value be able to set/match), because with that i could always override the copy with a custom context to put the value on the clipboard.  
The reason it is important to be the same is that that column is not always a date.  and instead of having checks all over to determine type just to set the value (a pain and may not work all the time), would be easier/better to have it as i need (in this case same dsiplayed) already in the property.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 28 Sep 2016, 08:36 AM
The underlying value is a .net DateTime object. Calling ToString() on it returns a format depending on your locale settings.
0
Abba
Top achievements
Rank 1
answered on 29 Sep 2016, 04:09 AM

So there is no way to read/use the actual displayed (formatted) text?  It could save effort of having to keep converting.

Also, In your post you mentioned it only appears for you at the cell level, but when I tried copy/paste at the row level (not just on the cell) and it also incorrect incorrect for me.  Unless it is because i'm not on the latest version.  
In any case, the workaround/fix would be helpful as I copy paste all data or when not using the context.

 

0
Hristo
Telerik team
answered on 29 Sep 2016, 03:12 PM
Hi guys,

Thank you for writing.

Abba, as Erwin said calling the ToSting method on a DateTime objects formats it according to the current culture. Please check the following MSDN article providing additional information on the available options: DateTime.ToString().

The displayed text for a DateTime value in the grid is set according to the string format of the column. Once you access the cell value you can call its ToString method and pass as an argument column`s format, e.g. like this: 
string stringFormat = ((GridViewDateTimeColumn)this.radGridView1.Columns["Date"]).FormatString;
string formattedValue = ((DateTime)this.radGridView1.Rows[0].Cells["Date"].Value).ToString(stringFormat);

Regarding the issue, the fix will handle a scenario in which a string format is set on the DateTime column and once copied the data will be formatted according to the applied format.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
Abba
Top achievements
Rank 1
Answers by
Abba
Top achievements
Rank 1
erwin
Top achievements
Rank 1
Veteran
Iron
Hristo
Telerik team
Share this question
or