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
170
[UltraGrid] Dynamic creation of columns causing NullReferenceException on UltraGridColumn.Editor
posted

Hi all,

I am working on a piece of code that should be able to display a set of data which is unknown on compile time: meaning I want to execute SQL statements, without knowing the model before execution.

Since the rows are in my case returned as object arrays (due to a generic transport model), I have to bind them at runtime.

This is the code I use for the moment:

List<UltraGridColumn> columns = new List<UltraGridColumn>();
int i = 0;

foreach (string entityField in actionTable.FieldDefinitions)
{
UltraGridColumn column = new UltraGridColumn(entityField, i++);
column.Header.VisiblePosition = i;
ultraGrid1.DisplayLayout.Bands[0].Columns.Add(column);
}

this.ultraGrid1.DataSource = actionTable.Result; // this is an object array.

In the InitializeLayout event I try the following:

UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns["fieldName1"];

if (column.Editor == null)
{
//execute some code
}

Then at the line with the "if (column.Editor == null)" a NullReferenceException is thrown. Does anyone have a clue why?