First I'm using the following:
I would like to allow the user to select the type of summary for a column, but the "Sum" is disabled for some reason.
My settings in the UltraWinGrid Designer are as follows:
For some reason when the user clicks on the column to dislplay your "Select Summaries" form and the "Sum" option is disabled. What do I need to set to have this enabled? From the Designer? By the way my program will display the sum total from code! But thats not the way we want this to work.
Also I tried inserting pictures for your benifit, but alas YOUR posting form will not accept any! Whats up with that?
Thanks ahead of time.
Patrick
Hi Mike
Yes that is what we are currently doing in order to get it to display as "01:30" - the cells will not be editeable.
I've already tried changing the field to a TimeSpan but the Ultragrid greys out Sum and Average, so that's a non-starter
This is really a 2-stage process
(1) Choose a datatype that will cause the UltraGrid to enable the Sum and Average checkboxes - this seems to only be the INT type.
(2) If possible format the actual displaying of the cell to be "01:30" - the ultragrid would still be treating the values as ints and hence be enabling Sum and Average. Is this possible ?
I've tried the Columns.Format property but the format entered depends upon the datatype of the column eg "c" will cause a timespan to be formatted "00.01:30:00" but will have a different effect if the datatype is INT. So I don't think it is possible using Columns.Format.
Could Infragistics.Win.UltraWinGrid.ColumnStyle be useful ? I've tried various permutations without success.
Any additional suggestions/feedback would be greatly appreciated!
regds
Simon
Hi Simon,
So how are you currently taking the integer value and formatting it for display in the grid as a string?
Also... is this field editable by the user?
There's no built-in support in DotNet for taking an integer and formatting it as hours and minutes except maybe by creating a TimeSpan object.
But if this field is not editable, then it would be very easy for you to format the data using your own custom FormatProvider.
Hi,
Any more thoughts on the above ? Is it a bit clearer what we are trying to do ?
thanks
I think we're taking slightly cross-purposes... and possibly there is confusion over terminology ;)
The actual time value is in minutes and is stored as an integer in the database and treated as an integer elsewhere in the code.
Also, when you talk about "storing" do you actually mean "displaying in the ultragrid" ?
We want to display this value in the Ultragrid but not as minutes (ie. 95) but in HH:MM format "01:35" and so are using ToString() (with format parameters) before assigning it to the ultragrid column. However because it is a string in the Ultragrid, Sum and Average are greyed out.
You stated "So if you can, you are much better off storing your numbers in a numeric type and then simply formatting the display."
Do you mean "storing" it as an integer in the Ultragrid ? Once the value is assigned as an integer to an Ultragrid column, however do you format (to a string) it after that ?
The order I am doing this is:
(1) Value is integer = 95
(2) Format to string = "01:35"
(3) Assign "01:35" to Ultrgrid column
(4) Ultragrid displays "01:35" (what we want) but Sum and Averrage are greyed out.
How else would this be done (if we want to retain the HH:MM format in the Ultragrid)
sgarstin said:I think you mean there is no support in DotNet for formatting an integer...
No, that is not what I meant. I meant string.
You can format an integer by calling the ToString method and passing in a format. This is true of all numeric and date types. The string data type is the one that does not have an overload of ToString that takes in a format. So you cannot format a string.
sgarstin said:But anyway, the DataType is string but we were wanting to know if we could get into the behind-the-scenes code that is called when clicking the Sigma on the UltraGrid - and tailor it.
I'm not quite sure exactly what your goal is here, so it's tough to answer the question.
Storing numeric data as a string is a really bad idea. This will cause all sorts of problems. Sorting, filtering, and summaries will all have problems. So if you can, you are much better off storing your numbers in a numeric type and then simply formatting the display.
If you want to store your data as strings, then the only way you could make the summaries work is to handle them yourself. You can do this by using an ISummaryCalculator. What you would have to do is handle the Before/AfterSummaryDialog event. You could examine the summaries that exist and then replace them with Summaries of your own that do your own custom summary calculations. But this is a lot more work than just formatting the display. And it won't help with sorting or filtering, so if you want to use those features, you will have to add similar code to handle those operations manually.