Hi there
We are using v12.1.20121.2038 of the UltraWinCalcManager in combination which the UltraWinGrid
I would like to display the FormulaBuilderDialog for a cell via a right click context menu item and have the formula effect a single UltraGridCell only rather than the entire UltraGridColumn or a SummaryColumn, which is what the Formula Builder At RunTime sample does.
Am I correct in thinking that because the UltraGridCell does not implement the IFormulaProvider interface that it cannot be done?
Is there a workaround via another property/object related to the UltraGridCell?
Is this possible and if so how? Do you have any samples?
Regards
geoffhop
Hi,
I'm confused. How are you applying the formula to the cell? The grid does not support that.
Are you saying that you just want the user to build a formula and then have the cell simply display the text of that formula in the cell? If so, then I missed that in your original post.
If that's what you want then using a hidden column is not a bad idea. But I think using a hidden TextBox would be more efficient, since it would only require one calculation instead of one for every row. But as you said, if you only have 120 rows, it doesn't matter that much. And you could read the formula out of the column and then immediately clear it out, also.
Thanks Mike
I will look into that. As a workaround I have added a hidden unbound column to the grid which is used to provide the interface to the FormulaBuilderDialog, the calculated formula is then copied from this hidden column to the cell I actually want to display the result it. Not the most efficient thing ever but it works and I will never have more than 120 rows in the grid so I can wear the overhead. But your thought on the UltraTextEditor may provide a more efficient technique so I will give it a try.
Thanks again
geoffhop said:Do you have an example/sample of hooking up the FormulaBuilderDialog to an UltraTextEditor?
Hm... I don't have a sample of this off-hand, but it should be pretty easy. It's very similar to the way you do it in the grid. The grid sample has a method called ShowFormulaBuilderDialog which takes in a FormulaProvider. So you can use the same method, it's just a question of getting the FormulaProvider for the UltraTextEditor. For any simple control like this, you could use the CalcSettings, which you can get from the UltraCalcManager.
CalcSettings calcSettings = this.ultraCalcManager1.GetCalcSettings(this.ultraTextEditor1); this.ShowFormulaBuilderDialog(calcSettings);
geoffhop said:Do you think it would be feasible to to somehow manipulate a hidden UltraTextEditor that is hooked upto a FormulaBuilderDialog with the value of the Text box just pointing to the value of an UltraGridCell?
It might be feasible, but there are a couple of issues you would have to work out.
I'm not sure if the CalcManager looks at the Visibility of a control. I don't think it does, but if I am wrong, you might have to hide the control by positioning it off-screen instead of setting Visible to false.
Then you would have to handle copying the value from the UltraTextEditor into the grid cell. So I suppose you could just trap the TextChanged property for that.
Thanks again Mike
Do you have an example/sample of hooking up the FormulaBuilderDialog to an UltraTextEditor?
Do you think it would be feasible to to somehow manipulate a hidden UltraTextEditor that is hooked upto a FormulaBuilderDialog with the value of the Text box just pointing to the value of an UltraGridCell?
Well... no. There's no control in the WinForms suite that would allow you to apply a formula to a single cell.
The only thing I can suggest is that you don't use a single control - you could use a bunch of TextBox (or UltraTextEditor) controls and apply a formula to each one individually. Of course, this will have serious memory and performance implications if you are creating a large number of rows and columns.