Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
495
Receiving an ArgumentException when referencing an UltraGrid column in UltraGrid InitializeLayout event
posted

Hello,

I am running into the issue described in the subject line. I have an UltraGrid in my WinForm application to which I bind a DataSet coming from a custom business object (e.g

gv.DataSource = BAL.Orders.GetAll()
gv.DataBind();

)

 The embedded Dataset that is returned has an embedded DataRelation object  which associates an EmployeeID and ProcessingDate between the two tables that the DataSet contains and as such displays appropriately showing the first DataTable data in Band[0] and the second DataTable data in Band[1].

In the InitializeLayout Event however I am running into a problem where I am referencing a particular column in the grid (and that data in this particular column is not one of the data elements that make up the embedded DataRelation of the DataSet, but rather just one of the several columns that the first DataTable displays in the Grid band[0] columns) .

The issue I am encountering on build is an ArgumentException - was not handled.
Key not found
Parameter: key

.... when I make a reference to the column which I am setting up to use in a Summary in the Grid's header. Here is my code:

 

 

 

 

 

 

 

 

UltraGrid 

 

 

gv = this.gvCompanyEarnedHours;
UltraGridBand band0 = gvCompanyEarnedHours.DisplayLayout.Bands[0];
UltraGridColumn colActual = band0.Columns["ActualHours"]; <-- Exception here
UltraGridColumn colEarned = band0.Columns["EarnedHours"];

 

 

 

 

//SummarySettings _settings1 = band0.Summaries.Add("SummedActual", SummaryType.Sum, colActual);
//SummarySettings _settings2 = band0.Summaries.Add("SummedEarned", SummaryType.Sum, colEarned);
// gv.DisplayLayout.Bands[0].Summaries["SumActual"].Appearance.TextHAlign = HAlign.Right;
// gv.DisplayLayout.Bands[0].Summaries["SumActual"].DisplayFormat = "{0:###.#}";

I am at a loss here as to why it would be complaining about some missing parameter key? This has been an absolute shopstopper for me, short of pulling of my hair out.

Thanks,
Paul