Embedding a usercontrol with a button. Need the following behavior. Getting closer but could use some assistance please..
1. When any cell in a row is clicked the entire row displays highlighted (including cell with user control). The usercontrol should be active so in this case the button should be active and if clicked should "work"
2. If a usercontrol cell is clicked, the entire row should be selected & highlighted and the usercontrol should "work". In this case if a button on a given row is selected the row should become selected & highlighted and the button click event should fire.
Thanks in advance.
In addition to CellClickAction (which exists on the Override and also on the UltraGridColumn), you should check out the EnterEditModeMouseBehavior property on the UltraControlContainerEditor. This property allows you to forward the click messages to the EditingControl when the user clicks on the cell and it's not in edit mode. This only makes sense if the RenderingControl and the EditingControl are the same type or at least look the same and have the button in the same place, of course.
Thanks Mike. I think I'm having a problem understanding how putting a control in a cell works.
When i try and grab an instance of the object in the cell to set a property (eg when putting a ultraformattedlinklabel in), the cell is actually linked to a single instance which of course sets the property for every cell in the column instead of just for that cell.
On the initialize layout I'm:
URLLinkEditor URLLinkEditorControl = new URLLinkEditor(ultraFormattedLinkLabelEditor, ultraFormattedLinkLabelRenderer);
URLLinkEditorControl.EnterEditModeMouseBehavior = Infragistics.Win.UltraWinEditors.
EnterEditModeMouseBehavior.EnterEditModeAndClick;
layout.Bands[0].Columns[2].Editor = URLLinkEditorControl;
------------
I'm assigning an instance of URLLinkEditor (my class) with a reference to the 2 controls instantiated on the form (which is what the example shows)
but this results in an undesirable situation where I need to set properties on the Link object differently for each cell in the column.
Could you please clarify how I can make this work. It's holding things up on multiple fronts where we need to do similar things.
Thanks, S
I'm not sure I follow you.
It looks like in this case, the UltraControlContainerEditor needs two instances of your control: one for the EditingControl (which would be used for the cell that is currently in edit mode) and one for the RenderingControl (which is used for all cells that are not in edit mode).
You should not have to deal with setting properties on your control yourself. You just tell the UltraControlContainerEditor which property on your control corresponds to the value of the grid cell and the editor will handle everything from there.
Basically, what happens behind the scenes is that when the grid does to draw a cell that is not in edit mode, it sets the value and possibly some appearance properties like BackColor and ForeColor on the RenderingControl and then draws the control onto the grid cell.
Mike,
Actually I have 2 issues. (this one is the priority)
The first issue has to do with a usercontrol that we've created that has alot of information on it. We use this usercontrol in a number of forms and now need to use it in cell.
The grid will has a list of dates in Band0. Underneath in each Band1, Col0, there will be 1-->many rows. Each row containing the usercontrol with lots of information populated. No editing of this data is needed, just display.
The grid datasource is a List<business object>. The business object looks like this:
DateTime WorkDate;
List<MyPlanItem> MyPlanItems {get;set} ;
MyPlanItems is an EF Entity with it's relationships and data. The usercontrol understands this structure. The contol exposes a "Value" property that can be set thereby populating the control.
When the application is run, the grid displays with the dates in Band0. There are "+" marks for each date (as is desired and expected). When a "+" mark is clicked however an error from the overridden RenderValue which seems to be returning a string and not a MyPlanItem for each row under a specific date.
My sample data has 3 dates each with multiple MyPlanItems. When I inspect the grid cells, I see the dates in Row[0-2].Cell[0] and I see a list/collection of items in Row[0-2].Cell[1]. In other words it looks like the data I would expect in Band0 is there and does display properly, but the Band 1 rows that are to contain the usercontrol doesn't work.
We need each MyPlanItem (MyPlanItems[n]) directly used as the datasource (Value) for the usercontrol for each row under a date.
I don't seem to understand how to tell the grid to set the usercontrols Value property to the corresponding MyPlanItem.
a. How can I tell the Grid what data to use to populate Band 1 rows containing our usercontrol? I was thinking it would be automatic, but if not please assist with a sample.
Thx in advance....
ps.
The 2nd issue I'll ask once this is resolved since this is priority 1.
Okay, so if you bind the grid to a data source like you describe here, then the grid will show the dates in the root band. The child rows of each parent row will be MyPlanItem's. But the MyPlanItem's in the list represent rows, not cell. So the grid will display the properties of the MyPlanItem as columns in the child band. There is no single column that contains a MyPlanItem object, by default.
But I think it can be done with a little clever coding.
What you could do is handle the InitializeLayout event of the grid and hide all of the columns in the child band. You don't want any of the individual properties of the MyPlanItem to display as a column. Then... you add an unbound column to the child band and set it's DataType to MyPlanItem. You now have a single column that is capable of displaying the MyPlanItem instance of each row.It is to this unbound column that you assign your ControlContainerEditor with your UserControl as the RenderingControl. You should not assign an EditingControl, since you don't need to allow editing.
Then what you do is handle the InitializeRow event of the grid. In this event, you populate the value of the unbound cell with the MyPlanItem from each row. So in InitializeRow, you trap for rows in the child band and set the value of the cell to the ListObject property of the row. ListObject returns the underlying data object from the data source which the row represents, so in this case, it will be the MyPlanItem.
If no editing is needed, then that's it - that's all you need to do.