Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hello support staff,

                                    I have been using your DevExpress grid for many years. Recently i have attempted for the first time to use a TcxEditRepositoryTimeItem in one of our grid's columns but are having some problems with it. Here are the steps I have taken so far...

                                    I have added into a EditRepository component the TcxEditRepositoryTimeItem. The resulting item has been assigned to one of my column's Repository value... i.e. grid.GridView.Columns[1].RepositoryItem := cxEditRepository1TimeItem1;

                                    I have used the very similar Datetime repository items in other columns with no problems. When I set one of the column's cells with a double value, the Datetime component accepts it and renders a readable date and time. If i do the exact same style of assigning a double value to a cell in the TimeItem column, all that is shown is the double value. It is not repainted as a value such as "12:30 AM". When my form is first created and the grid is being populated, if the initial double value happens to be 0, the cell paints a "12:00 AM" as expected. Any other value doesn't seem to do so.

                                    In my attempts to solve this issue, i have also tried to do a direct assignment to the Time variable of the component. i.e. TcxCustomTimeEdit.Time. The help file says it is as simple as reading or writing to the Time property.  It is not readily or easily available through the TcxEditRepositoryTimeItem, so i tried code such as... 
                                    [Delphi]
                                    TcxCustomTimeEdit(grid.GridView.Columns[1].RepositoryItem).Time := (a double value);
                                    Doing things this way always results in an access violation in the component's SetTime function. I am assuming the typecasting is somehow incorrect or something like that.

                                    So my question boils down to... After adding the TcxEditRepositoryTimeItem into a column, what is the necessary way to read and write to that cell? How do I access the Time property correctly from the Repository Item without a crash? A small sample code would be great.

                                    Thank you for your time,

                                    Terry Klacking
                                    Prediction Software Inc.

                                1 Solution

                                Creation Date Rating Importance Sort by
                                0

                                Hello,

                                I've attached a small test project, which demonstrates how to correctly set values to a data-aware GridView (via the DataSet and DataController). Please take a look at it. I believe this will help you to resolve the issue you faced.

                                P.S.: Please use code brackets for writing your code in the Question and Answer sections. This will highlight your code parts and make your posts look clearer. As a result, we will be able to process your inquiries faster.

                                Show all comments
                                • Ernest Eugene Chandler III 01.12.2017
                                  Thank you for the sample code, Mikhail. However, I do not think I am any closer to a solution. When i try to use the SetEditValue function, it throws an error about RecordIndex being out of range. I believe this is because your example is using a DBgrid that already knows its RecordIndex based on the focused row. I try to set this value before calling SetEditValue, but it still throws the error. Also, according to the help files, SetEditValue should not be called inside a BeginUpdate/EndUpdate block. Since we are using and loading an unbound grid and not a DBgrid, the Begin/EndUpdate is essential.

                                  We are using the Values property in all other columns, no matter what RepositoryItems are being assigned to a given column...
                                  [Delphi]
                                  GridView.DataController.Values[RowNumber, ColumnNumber] := ValueToSet;
                                  I am curious why this does not work for the TcxEditRepositoryTimeItem? I also tried to find a "Value" property like in your example, but could not find one within TcxEditRepositoryTimeItem.

                                  To try to reproduce what i'm seeing, I would recommend to alter your test project to not use a DBgrid, and just a regular unbound grid. Add a TcxEditRepositoryTimeItem as the repository item of 1 column, and try to assign a double value into a specific cell in that column. (not by typing in the cell, but assigning a value at runtime). 

                                  Thank you for your support and patience,

                                  Terry
                                • Mikhail (DevExpress Support) 01.12.2017

                                  1) The DataController.Values method requires the Record index as a parameter, but not the Row one.
                                  2) Please provide us with a small test project to demonstrate the current behavior and the problem you faced.

                                • Ernest Eugene Chandler III 01.19.2017
                                  Mikhail,

                                  Sorry for the delay. Some other programming matters needed my attention. I have enclosed a zip file of a "small" project (although Delphi overhead is killing us for exe sizes).

                                  In the example program, you will see 3 columns in a Banded Grid and 2 buttons. It is not a DB grid. Using the "Assign Time" button will attempt to put a value of "0.5" into the Time repository item of the middle column. The value is not translated into "12:00PM" or anything similar to that format. It will just display 0.5. As a comparison, if you use the "Assign Datetime" button, it will put a double into the 3rd column, which is a Datetime repository item. Setting this value translates the value into a readable date and time format in the cell. So, why can't the Time repository item translate the double value into a proper time format in its cell the same way the Datetime cell does?
                                • Ernest Eugene Chandler III 01.19.2017
                                  Mikhail,

                                  Sorry for the delay. Some other programming matters needed my attention. I have enclosed a zip file of a "small" project (although Delphi overhead is killing us for exe sizes).

                                  In the example program, you will see 3 columns in a Banded Grid and 2 buttons. It is not a DB grid. Using the "Assign Time" button will attempt to put a value of "0.5" into the Time repository item of the middle column. The value is not translated into "12:00PM" or anything similar to that format. It will just display 0.5. As a comparison, if you use the "Assign Datetime" button, it will put a double into the 3rd column, which is a Datetime repository item. Setting this value translates the value into a readable date and time format in the cell. So, why can't the Time repository item translate the double value into a proper time format in its cell the same way the Datetime cell does? 
                                • Ernest Eugene Chandler III 01.19.2017
                                  Mikhail,

                                  Sorry for the delay. Some other programming matters needed my attention. I have enclosed a zip file of a "small" project (although Delphi overhead is killing us for exe sizes).

                                  In the example program, you will see 3 columns in a Banded Grid and 2 buttons. It is not a DB grid. Using the "Assign Time" button will attempt to put a value of "0.5" into the Time repository item of the middle column. The value is not translated into "12:00PM" or anything similar to that format. It will just display 0.5. As a comparison, if you use the "Assign Datetime" button, it will put a double into the 3rd column, which is a Datetime repository item. Setting this value translates the value into a readable date and time format in the cell. So, why can't the Time repository item translate the double value into a proper time format in its cell the same way the Datetime cell does? 
                                • Ernest Eugene Chandler III 01.19.2017
                                  Mikhail,

                                  Sorry for the delay. Some other programming matters needed my attention. I have enclosed a zip file of a "small" project (although Delphi overhead is killing us for exe sizes).

                                  In the example program, you will see 3 columns in a Banded Grid and 2 buttons. It is not a DB grid. Using the "Assign Time" button will attempt to put a value of "0.5" into the Time repository item of the middle column. The value is not translated into "12:00PM" or anything similar to that format. It will just display 0.5. As a comparison, if you use the "Assign Datetime" button, it will put a double into the 3rd column, which is a Datetime repository item. Setting this value translates the value into a readable date and time format in the cell. So, why can't the Time repository item translate the double value into a proper time format in its cell the same way the Datetime cell does? 
                                • Mikhail (DevExpress Support) 01.20.2017

                                  Hello,

                                  Your approach is incorrect. You are using a string column to work with Time. I recommend you use the correct data type (i.e., DateTime) and this will resolve the issue you faced. Please try this.

                                  Nevertheless, we will discuss the issue with converting a value to time in the String column.

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners