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
70
Moving ValueLists with Rows
posted

Hi Everyone,

I have an UltraGrid with two bands; the first band contains non-editable parent rows, and the second band has an editable column that may have both ordinary and combobox cells. The value list for each combobox cell is different from others, and it depends on the parent row properties. The UltraGrid is bound to a BindingList, and the value lists, where needed, are instantiated as UltraDropDowns that are bound to a BindingList property of the row's ListObject. The displayed properties implement INotifyPropertyChanged interface to notify the grid of changes.

The code follows:

RDSViewParameter parameter = propertyRow.ListObject as RDSViewParameter;
if (parameter.ValueList != null)
{
UltraDropDown dropDown = new UltraDropDown();
dropDown.SetDataBinding(parameter.ValueList, null);
propertyRow.Cells[1].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
propertyRow.Cells[1].ValueList = dropDown;
dropDown.DropDownWidth = 0;
dropDown.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
dropDown.DisplayLayout.Bands[0].ColHeadersVisible = false;
}

Everything appears to work fine, until I want to reorder the parent rows (first band) through reordering of the bound BindingList. The child rows move with parent rows as expected, but the ValueLists don't! As a result, the moved child row cells often have incorrect styles (Default vs DropDownLists) and incorrect value lists. I tried manually updating value lists (without binding them), but I god all sorts of errors. After searching those errors, I found out that I should not tamper with an UltraGrid that is bound to a DataSource, and figured this is not a good practice. My question is how I can correctly move value lists with cells as their parent rows are reordered.

Any help would be appreciated.

Thanks.

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi, 

    Re-ordering the bound list will not have any effect on the grid. The grid stores it's own sort order for the row. So what are you doing to the grid in order to get it to reflect the new order of the rows? 

    Also, what event are you using to set the ValueList on the cell? The best event to use is the InitializeRow event. That way, if any value in the row changes or if the row is re-created for some reason, the code will fire again and re-set the ValueList. 

    I can't think of any reason why the ValueList on a row would change to the wrong ValueList, unless something in your code is doing that. The only other possible explanation is that the grid is somehow re-using the UltraGridRow object and somehow hooking it up to the wrong row, but I've never seen any situation in which that happens. So it seems like your code is doing something very unusual here.

Reply Children