Here's the code, pretty much copied and pasted from Infragistics example:
FYI, InitLayout event is fired during InitializeLayout of my base grid class. The code all executes fine, the only problem is that my sum does not display any sum at all!
public static void InitLayout(JWWinGrid grid) { if(!grid.DisplayLayout.Bands[0].Summaries.Exists("Total")){ grid.DisplayLayout.Bands[0].Summaries.Add("Total", Infragistics.Win.UltraWinGrid.SummaryType.Formula, grid.DisplayLayout.Bands[0].Columns[_CUSTOMER_PRICE], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn); grid.DisplayLayout.Bands[0].Summaries["Total"].Formula = "sum([" + _CUSTOMER_PRICE + "])"; grid.DisplayLayout.Bands[0].Summaries["Total"].DisplayFormat = "Total = {0}"; } } public static void InitGrid(JWWinGrid grid) { grid.BindGrid(SalesOrderDataSource()); Infragistics.Win.UltraWinCalcManager.NamedReference reference = new Infragistics.Win.UltraWinCalcManager.NamedReference(); reference.Key = _CUSTOMER_PRICE; grid.CalcManager.NamedReferences.Add(reference); .........
}
And another question -- are there any examples of using a formula with a variable that IS NOT in a column. For example if I had an overall discount field on my form that I wanted to calc against my total, how would I use that value in a formula..?
Sorry to ask so many questions, I have never done the summaries before so I am getting a little frustarted trying to figure it all out. Thanks again in advance.
So my remaining questions are:
Hi,
Well, the only reason I can see why the summary would not work is if there is no UltraCalcManager on the form or hooked up to the grid. Do you have an UltraCalcManager Component on the same form with the grid? Are both the grid and the calc manager on the form at design-time? If so, you might want to just look at the form designer code and make sure the grid's CalcManager property is getting assigned properly. It might have somehow gotten corrupted.
I'm not exactly sure what you maean by an editable value in a summary. Summary fields are not editable. That would not make any sense.
Also, if you want this affect, make sure not to "force list" or whatever the property is... it makes it so that if you're trying to filter the grid, but filter down to an item that doesn't exist, you can't exit the combo box. It was a mistake I made that I scratched my head at for a good 20 minutes...
Mike, I have no idea how you know so much but you have yet to give me a wrong answer! Thanks bro!
BTW, if anyone wonders, you can force the dropdown list to "drop down" or hide itself by calling "ToggleDropDownI()" method. You can test if the control is in drop down state by calling "IsDroppedDown."
For the effect of dropping down upon entering the text area of the combo box, I believe I put this in my on click method. For the benefit of everyone, let me dig it up real quick:
private void cboClient_Click(object sender, EventArgs e) { if (!cboClient.IsDroppedDown) { cboClient.ToggleDropdown(); } }
If you are programmatically creating the CalcManager, then it won't be hooked up to the grid. So you probably just need to set grid.CalcManager = myCalcManager.
You could certain set the formula on the summary to take into account some kind of discount. But the discount will have to be part of the calc network. So your discount either needs to be in a control (like a text box or label on the form) or you could put it into a NamedReferences on the CalcManager.
I am trying to add the calcmanager programmatically to the form and not through the designer -- I guess that may actually be the case. Thanks Mike I'll take a look and let you know.
When I say editable summary, what I mean is that I would like to have a "total" as a SUM(COL) and then a user entered field for "discount" to the left of the total that a user could enter an overall discount for the summary of all prices. Not sure if that made sense, but right now I just have a textbox I'm using for an overall discount outside of the grid. Let me know your thoughts!