I need to dynamically set a column in an UltraDropDown based on a value in the UltraGrid row from which it is being dropped. In other words I want to get a reference to either the UltraGridRow or the UltraGridCell which was clicked on, to use in the InitializeRow event of the UltraDropDown.
It isn't an parent control and I can't seem to find any combination of UIElements which would help out.
Things like
UltraDropDown u = UltraDropDown(sender);
UIElement element = u.DisplayLayout.UIElement;
element.GetAncestor(....... GetContext(.
None of the above lead anywhere. Other than a hoaky getting a client by assuming the point is above the dropdown and using something like ElementFromPoint, does anyone have any way to get the UltraGrid row or cell dropping down the list?
Hmm after posting this, I realized that the cell and row should be active, so I should be able to get them indirectly. Be better of course if there was a more direct way.
Hi,
I don't think this will work, even using the ActiveCell. InitializeRow is only going to fire the first time the rows of the dropdown are initialized, not every time you drop it down. Also, if you change the values of either the DisplayMember or ValueMember columns on the list, this will end up affecting other cells in the grid column, because they may no longer be able to translate values.
Perhaps if you could explain in a little more detail exactly what kind of functionality you are trying to acheive, I might be able to offer you a suggestion for a better way to do it.
Thus the datasource for every row's dropdown was different. And thus the IntializeRow fired every time the UltraDropDown was dropped down. And I was able to get the value from the grid.ActiveCell.Row.Cells["xxx"] that I needed.
Although this is solved, it would be interesting to find out if there is a way to refer to the cell that dropped down the list from the UltraDropDown since it's not a parent relationship, but in fact the cell can be pouplated by the dropdown ValueMember and DisplayMember if a row is selected, so there is some relationship. (in my case I did not want the cell populated, since the ultradropdown was informational only and purposely set up so that the ValueMember and DisplayMember was not set).
Nuff said. ActiveCell it is... I think I was just looking to understand how the UltraDropDown was attached to the cell, and the IValueList interface is a good enough answer.
Before I mislead anyone reading this thread about using the UltraDropDown as a informational display only, it wasn't as easy as I thought. The cell has to be editable before the list drops down. This causes a row selected in the dropdown to update the grid cell value as the list is closed even though I didn't want it to and even though I don't have either a ValueMember or DisplayMember set.
The list of things I had to do to get the UltraDropDown as a display only auxillary grid of information was the following:
In the Grid BeforeCellListDropDown event, set the datasource and then add a statement with a switch on the cell key. (stops painting otherwise there is a visual glitch as the grid cell is updated and then repainted back to it's original value)
grid.BeginUpdate();
In the Grid CellListSelect event, add a statement with a switch on the cell key. (causes the cell update when the list collapses to be cancelled)
e.Cell.CancelUpdate();
In the Grid AfterCellListCloseUp event, add a statement with a switch on the cell key. (allows painting to resume again)
grid.EndUpdate()
In the DropDown RowSelected event, add a statement to prevent a row in the dropdown from being selected (information only - no need to highlight)
if (e.Row != null) e.Row.Selected = false;
All this allowed me to achieve my objective and was not as straight forward as alluded to in the first posts.
Incidentally in working through this I came across the way to find the row or cell that drops down the list from the UltraDropDown. The RowSelected event (and others) in the UltraDropDown provide an e.Owner property which is the UltraGrid that dropped down the list. Not that useful now since I knew which grid dropped down the list and grid.ActiveCell worked out for me, but available if necessary as the Owner of the control, if you were doing something dynamic and didn't know the owner of the UltraDropDown.
I think if you set CellActivation on the column to NoEdit (or maybe ActivateOnly) and then set the column's ButtonDislpayStyle to Always, it might also work the way you want.
I tried both NoEdit and ActivateOnly and while the button displays, it does nothing when you click it, so it appears that AllowEdit is the only case where the dropdown appears. That is unless there is some combination of other properties which I have set which is disallowing it.
I tried playing with CellClickAction (set to Edit) and CellDisplayStyle (set to FullEditorDisplay) in case the defaults were overridden but they didn't help either.
Couldn't see anything else that could effect it.
Okay, it looks like this does not work with an UltraDropDown, it only works with editor buttons.
If you just want to display a dropdown list for information and not let the user choose from the list or edit the cell, then you can do this:
Add an UltraTextEditor to the form with the grid.
Instead of an UltraDropDown, use another UltraGrid.
Use the ButtonsRight collection of the UltraTextEditor and add a DropDownEditorButton to it. Set the Control property of the button to the second grid.
Then set the EditorControl property of the grid column to the UltraTextEditor. This gives you a dropdown grid in the cell.
Now you can set the CellActivation to ActiveOnly and the ButtonDisplayStyle to Always and the user can drop down the grid within the grid.
An interesting bonus to this is that the grid on the dropdown is UI active. So you could allow the users to filter or sort it. You could put summaries on it, etc. You could even make it editable.
menziesetcd said:I will look into how/where to create CreationFilters as I am not familiar with them.
Using two editors is probably easier.
But if you want to try the CreationFilter approach, I recommend that you get the Infragistics UIElementViewer Utility. It will be a big help.
Thanks Mike.
I will look into how/where to create CreationFilters as I am not familiar with them.
On the issue of closing the dropdown, i did implement a workaround where I simply set the focus back to the originating cell which worked ok. I will look into your suggestion of DropDownManager and Closup as that may be a more elegant solution.
Many thanks.
menziesetcd said:Is there absolutely no way, to have a button which displays on mouse enter and with CellActivation ActiveOnly to avoid in-situ editing of the cell?
I was not able to find a way to do this. But you could use a CreationFilter to remove the button for cells in which it should be disabled. Or you could even use a different editor on those cells - like an UltraTextEditor with no buttons.
menziesetcd said:The second issue was that my user control editor has a Apply button which user must click to save any changes to database. So when Apply is clicked, I need to simulate the normal behaviour that occurs when the user cancels/completes a cell dropdown edit. I tried hiding the usercontrol, but am then left with an empty gray panel of size/location of the "hidden" user control which only goes away if I click elsewhere in the grid.
You just need to close the dropdown. If you have a reference to the cell, you can use cell.EditorResolved to get the editor, then cast that into an EmbeddableEditorButtonBase and then get the ButtonsRight collection. Once you have that, there's a CloseUp method on the button.
Another alternative is to use the static CloseUp method on the DropDownManager which will close any open dropdown windows. Typically, this is okay, since there is usually only one dropdown open at a time.
Hi Mike
I tried your idea of using an UltraTextEditor with a DropDownEditorButton to launch a custom user control. I had two issues. The first, as above, is the problem that the button only works if display style is Always - this looks awful in a grid with multiple editable columns, expecially as the edit-capability of each cell is conditional on other data in each row, and havng the button always display looks very cluttered. Is there absolutely no way, to have a button which displays on mouse enter and with CellActivation ActiveOnly to avoid in-situ editing of the cell?
The second issue was that my user control editor has a Apply button which user must click to save any changes to database. So when Apply is clicked, I need to simulate the normal behaviour that occurs when the user cancels/completes a cell dropdown edit. I tried hiding the usercontrol, but am then left with an empty gray panel of size/location of the "hidden" user control which only goes away if I click elsewhere in the grid.
Any hints will be much appreciated.
Great suggestion. Changing my project since I will likely have to do this multiple times as the users gets used to the cell interface and want it on other screens. (Plus it enhances the functionality as you pointed out).