Home Forums WinForms controls Xceed Grid for WinForms Show datetime column as time with FormatSpecifier

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15167 |

    Hello

    I’m using Xceed Grid .net 3.2

    I have tryed to change the way a datetime column to show time.
    The column 5 contains data from a datetime field.

    If I use the ..

    gridControl1.Columns[5].FormatProvider = CultureInfo.CurrentCulture.DateTimeFormat;
    gridControl1.Columns[5].FormatSpecifier = “t”;

    Nothing happens, Then I tryed the version ..

    gridControl1.Columns[5].FormatProvider = CultureInfo.CurrentCulture.DateTimeFormat;
    gridControl1.Columns[5].FormatSpecifier = “HH:mm”;

    But again nothing happens. The datetime column is shown as datetime.

    Have I overlooked something?

    Imported from legacy forums. Posted by Devmann (had 3577 views)

    User (Old forums)
    Member
    Post count: 23064

    The default editor used by the grid in a DateTime column is a WinDatePicker, which does not support Time. You will need to either use a regular TextEditor and make the proper conversion to time, or wrap a control that supports Time into the CellEditorManager and CellViewerManager classes, to do what you want.

    Imported from legacy forums. Posted by André (had 297 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello again

    Now I have tryed to use a TextEditor.

    Before that I changed my DateTime in the select command to a string formating my datacolumn to HH:mm. And then converting the time format to string.

    Then I tryed to show the data and it works fine. But then editing I would like to use the mask 99:99. So I used the TextEditor like this.

    Xceed.Grid.Editors.TextEditor txtEdit = new Xceed.Grid.Editors.TextEditor(“99:99”);
    gridControl1.Columns[5].CellEditorManager = txtEdit;

    I also tryed the mask “##:##”.

    But when I use the mask I can’t edit the column in the grid. When removing the mask I can edit the column again. Way is that?

    Imported from legacy forums. Posted by Devmann (had 429 views)

    User (Old forums)
    Member
    Post count: 23064

    It is probably the conversion between the cell and the editor that is not right. Do you do this in the SettingControlValue and GettingControlValue events?

    We have a sample application that actually employs a WinTextBox (what’s underneath the TextEditor) to accomplish time display and editing.

    <a href=”http://www.xceedsoft.com/cs/download/XceedGrid/CSharp/OldEditorVsNewEditor.zip”>OldEditorVsNewEditor.zip</a&gt; (CS 2003).

    Find “Custom 1 – Time edition”, and look at the “new 1” example. It does exactly what you are looking for.

    Imported from legacy forums. Posted by André (had 303 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, I found the solution in the sample code ..

    Imported from legacy forums. Posted by Devmann (had 4970 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.