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
Hello Patrick,
Have you been able to check what is the DataType of the column in DesignTime? By default the DataType of the added columns in design time is System.String, and the "Sum" and "Avarage" options will be disabled.
Please let us know if you have any further questions.
Hi
Is there are way of intercepting this rule in code ?
I am displaying a list of time balances (hours) in the format 37:30, 40:00, obviously we need to display them as strings to format them this way.
It would be good to see the sum and average, even if it means converting these to minutes (integers), calculate the Sum and Average and reformat these as SUM = HH:MM, AVERAGE = HH:MM.
Is this possible ?
thanks
Simon G
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,
Okay... if the cell is not editable, that makes things a lot easier.
You are correct, the Format property won't help you by itself, because there isn't any support in the DotNet framework for formatting an int as hours and minutes.
There are basically two approaches you can take here.
1) Keep using Int and use Format and FormatProvider to do custom formatting. You can create your own IFormatProvider which will handle your own custom Format strings and format the int however you want it.
2) You could use Timespan and enable to the sum and average options by setting AllowRowSummaries on the column to True (instead of the default, which is BasedOnDataType). Of course, the grid won't know how to perform the sum or average on a TimeSpan column, so you would have to manually handle the actual calculations, also. How you do this will depend greatly on what version of the grid you are using.
Personally, I think option 1 is your best bet. Writing your own FormatProvider is pretty easy and you will be able to use the same FormatProvider and the same Format for both the column itself and the summaries.
Thanks for getting back to me and I agree, the first option seems the better one.
I'm not sure if it's possible to convert an integer to a datetime HH:MM format but will investigate - if you have an examples to hand that would be useful too ;)
Thanks for the continued support.
To clarify:
I'm not sure if it's possible to convert an integer to a datetime HH:MM format in a single format command..,
regds ;)
No, I don't think any of the dotnet data types support this format. But it should be enough to take an int and divide by 60 to get the hours and use the mod to get the minutes and build a string out of it.