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
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.
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 ;)
Hi Mike
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.
Simon
Sorry I didn't answer your first question:
The time is stored in a custom object WorkingTime and the formatting code is:
return String.Format("{0}:{1:00}", workingTime.Hours, workingTime.Minutes);
workingTime.Hours, workingTime.Minutes are both INTS
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.