Hi,
I am tring to add an unbounded column of edit buttons to a grid.
the assignment to the grid DataSource happends at runtime, and the rows attached there don't contain the defaultCellValue i wanted for these buttons (their buttons has no caption).
I tried to assign it manualy right after the binding:
private void InitData()
this.ultraGrid.DataSource = this.innerMultiDropDownValues.Values;
//foreach (UltraGridRow row in ultraGrid.Rows)
// row.Cells[editBtnColumnKey].Value = this.ultraGrid.DisplayLayout.Bands[0].Columns[editBtnColumnKey].DefaultCellValue;
}
But i got an exception because the Cells property for all the rows is null, although the DataSource is valid.
Can u please help me solve this issue, and also explain to me how to handle a mixture of bounded and unbounded columns?
Are you sure Cells is null? The Cells collection should never be null. Although it's certainly possible that the unbound column does not yet exist.
If you want a button in an unbound column with some text on it, the best way to do to it is to add the unbound column to the grid in the grid's InitializeLayout event. To set the text on the button, you should use the InitializeRow event and do something like this:
if (e.ReInitialize == false)
{
e.Row.Cells["my unbound button column"].Value = "The text I want on the button";
This is exactly what I did at first, but then I got the exception for the null Cell collection.
I think that my problem with this is conceptual. During life time of my editor object the user can assign a new DataSource to the grid. It doesn’t important when I add my unbounded column - whether I add it in the constructor (or alternatively ultraGrid_InitializeLayout) or after the DataSource assignment, In any case the ultraGrid_InitializeRow evant is being called twice for each row: in one of them the unbounded column exist and in the other it’s not…