Is it possible to use WinEditor in WinGrid? For example, if user click a cell in a particular column, I want to pop up a WinCalculatorDropDown.
If it is possble, mind providing a brief idea on how to do it in code?
This documentation might be of use to you. The WinGrid is so amazingly flexible, that you can do pretty much everything with it!
That article is for non-editor controls. It'sfar more complicated than you need here.
All you need to do in this case is place an UltraCalculatorDropDown control on the form with the grid and set the grid column's EditorControl property to the calculator dropdown control.
If you read the documentation page I linked above it shows that you have to handle the BeforeEditorButtonDropDown event for the UltraCalculatorDropDown. Scroll toward the bottom of that page you'll see the code for this event (it's under #20), and you can do something similar for the UltraCalculatorDropDown. It's really easy!
Thanks Torrey, but the problem here is that the CalcualtorDisplayValue has no setter.
Here's the steps to achieve what you're looking for. Keep in mind I'm assuming that your column that will contain the WinCalculator dropdown is of Decimal data type.
Here's the code I used in the two created events for step 6 and 7.
private void ultraCalculator1_AfterCalculationComplete(object sender, EventArgs e) { this.ultraGrid1.ActiveCell.Value = ultraCalculator1.DisplayValue; } private void ultraNumericEditor1_BeforeEditorButtonDropDown(object sender, Infragistics.Win.UltraWinEditors.BeforeEditorButtonDropDownEventArgs e) { if (this.ultraGrid1.ActiveCell != null && e.Button.Key == "CalcButton") { this.ultraGrid1.ActiveRow.Update(); for (int i = 0; i < this.ultraGrid1.ActiveCell.Value.ToString().Length; i++) { ultraCalculator1.PushButton(this.ultraGrid1.ActiveCell.Value.ToString().Substring(i,1)); } } }
I would imagine there could be a cleaner way of coding for the BeforeEditorDropDown event, but nearly every property I found was read-only for the WinCalculator.
Hi,
Torrey, the article you linked to is about placing a control on a DropDownEditorButton. That's useful if you want a dropdown in a cell with some control on it that is NOT an embeddable editor already. But that is unneccessary here. UltraCalculatorDropDown is already an editor control, so using the code in that sample is just a whole lot of extra work for no reason.
To get the value from the cell to show up in the calculator when you drop it down, all you have to to is set the CalculatorDropDownStyle on the UltraCalculatorDropDown control to KeepCurrentValue.
I totally blew that one! (*Aims the USB Nerf dart gun at his own head and fires*)
If it's any help I'll recap what Mike said to do.
Sorry if I caused any confusion! I'll stay away for a while and go find a mountain dew to wake up.