Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
TimeSpan - can not edit timespan value
posted

hi all,

i have a grid with a column that represent time interval (in WinForms). i set the column type to be system.TimeSpan.

each cell gets the default value of 8 hours and indeed, new rows in the grid shows 08:00:00 as expected.

the readOnly property is set to false, and when i try to edit the timeSpan value in the grid i get an error, even before pressing Save (i'm just clicking outside the cell).  i get an error which says :

"unable to update the data value: Value could not be converted to System.TimeSpan." 

 

this is how i defined the column- please advise what else am i missing.

thanks

       UltraDataColumn minimumTimeIntervalColumn = mProjectListData.Band.Columns.Add(MINIMUM_TIME_INTERVAL_IN_SECONDS_COLUMN_NAME, typeof(TimeSpan));

            minimumTimeIntervalColumn.ReadOnly = DefaultableBoolean.False;

Parents
No Data
Reply
  • 48586
    posted

    Hello,

    UltraGrid doesn’t  have a default editor for timespan.  It calls ToString()  method of the TimeSpan class in order to display the value in a text editor (default editor for the cells), when the user enters a value in the editor it can’t convert the string to the object of type TimeSpan. So you should assign UltraTimeSpanEditor as EditorCpomponent of the column. In InitializeLayput event of the UltraGrid you should add code like:

         UltraTimeSpanEditor editor = new UltraTimeSpanEditor();
                this.Controls.Add(editor);
                editor.Format = Infragistics.Win.TimeSpanFormat.Hours;
                e.Layout.Bands[0].Columns[“MINIMUM_TIME_INTERVAL_IN_SECONDS_COLUMN_NAME”].EditorComponent = editor;

    Please let me know if you have any further questions.

Children
No Data