DateTime Format Copy Select Value ALL DIFFERENT

9 posts, 0 answers
  1. Abba
    Abba avatar
    22 posts
    Member since:
    Jan 2013

    Posted 23 Sep Link to this post

    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.

     

  2. Abba
    Abba avatar
    22 posts
    Member since:
    Jan 2013

    Posted 23 Sep in reply to Abba Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 27 Sep in reply to Abba Link to this post

    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

  5. Hristo
    Admin
    Hristo avatar
    714 posts

    Posted 27 Sep Link to this post

    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.
  6. Abba
    Abba avatar
    22 posts
    Member since:
    Jan 2013

    Posted 28 Sep Link to this post

    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.

  7. Abba
    Abba avatar
    22 posts
    Member since:
    Jan 2013

    Posted 28 Sep Link to this post

    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.
  8. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 28 Sep in reply to Abba Link to this post

    The underlying value is a .net DateTime object. Calling ToString() on it returns a format depending on your locale settings.
  9. Abba
    Abba avatar
    22 posts
    Member since:
    Jan 2013

    Posted 28 Sep Link to this post

    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.

     

  10. Hristo
    Admin
    Hristo avatar
    714 posts

    Posted 29 Sep Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready