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).
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.
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.
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.
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: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.