Hello,
I am databinding my ultragrid to a class that has a property of type list . i would like to have it represented by a column, just like the other properties but inside of the cell i would like the items to be displayed as in a listview or a listbox - instead of the default tree structure of the grid. I am planning on setting the editorComponent of the column to a ultraListview.
Is there a way to achieve that behaviour?
Hi,
There's no way to do this directly. The grid will always treat a list as a child band. But what you could do is hide the child band (using the Hidden property on the Band).
Then you could add an unbound column to the grid's root band. The InitializeLayout event is a good place to do this.
In the InitializeRow event of the grid, you could read the values from the Hidden child band and populate the grid cell with some object that contains the data for the child rows. For example, you could set the Value of the cell in the unbound column to the ChildBands[0].Rows collection of the parent row.
lomsey said:I am planning on setting the editorComponent of the column to a ultraListview.
UltraListView is not an EditorComponent. So you can't set this directly, either. But... if you want to embed a ListView into a grid, you could use the UltraControlContainerEditor. In this case, you would probably need to do a little bit more work, because the ListView won't know what to do with a collection of grid rows. So what you would do is create a UserControl that contains a ListView and has a public property that accepts a RowsCollection. You would use this UserControl as the EditingControl and RenderingControl of the UltraControlContainerEditor. And you would set the EditingControlPropertyName and RenderingControlPropertyName to the property you added.
Now when you set the value on the grid cell to the rows collection, the editor will set your property to the rows collection and you can handle the property setter and populate the ListView with the data you want.
Hi Mike,
I have a similar requirement . I have a grid that lists data provided by the user, I have this specific requirement where in when the user clicks an edit button , the selected row has to load a listbox in its last column (which is otherwise a simple column) and it has to be done only for that row. I need to allow the user the ability to select some value from this listbox and need to save them in some userdefined object. Now what i did the following as per your advise in the ealrier post
1) I created a usercontrol (name - CtrlDummy)and added a listbox to it.Next , i populated some dummy items in the list box say A,B,C,D
2) I used UltraControlContainer (name - ultracontrolcontainereditor) in my form that has the grid . Now , on click of edit button i wrote the following code -
this.ultracontrolcontainereditor.RenderingControl = CtrlDummy;
this.grid.rows[0].cells[8].editorComponent = this.ultracontrolcontainereditor;
But with this, first i get an eception that the editingcontrol and renderingcontrol cannot be the same . Also if is set only the editingControl , i dont see any chnage in the grid column. Where as if i set the renderingcontrol property , the usercontrol shows up in the grid column. But it is very small in size and not editable also.
The usercontrol needs to be somewhat bigger in size and also it has to be editable.Please help!!
Hi RC,
I'm a little confused by exactly what you are trying to achieve here. It sounds to me like you just want a dropdown list in a cell. If that's the case, you don't need to jump through all of these hoops and use an UltraControlContainerEditor and a ListView. There are much easier ways to do that.
HOWTO:What is the best way to place a DropDown list in a grid cell?
Anyway... the EditingControl is used by the cell in edit mode to allow the user to edit the cell. The RenderingControl is used to draw all of the other cells which are not in edit mode. So you have to use two different controls. Typically, you would use two instances of the same type of control so that the cell looks the same whether it's in edit mode or not. You may want to take a look at the ControlContainerEditor samples that come with NetAdvantage.