I have an UltraGrid with cascading dropdown controls in a few columns. Depending on the value of one dropdown control, I would like to change the ToolTipText property on the next column cell in that row. I tried setting it in the UltraGrid's BeforeCellListDropDown event and below is the result.
I added a UltraToolTipManager and set the following
ruleTooltipManager.SetUltraToolTip(secondChoiceDropdown, new Infragistics.Win.UltraWinToolTip.UltraToolTipInfo("Select a Category", Infragistics.Win.ToolTipImage.None, null, Infragistics.Win.DefaultableBoolean.True));
That results in an empty tooltip bubble when hovering over the cell. In fact, there's an empty tooltip bubble when hovering over any cell.
The next method, on a cell with a dropdown control that is populated in BeforeCellListDropDown
e.Cell.Row.Cells[ColumKey].ToolTipText = "Select a Category";
Nothing happens when hovering over that cell (I had a breakpoint on that line and it hit it)
Hello Sam,
Instead of using the UltraToolTipManager, what I can suggest you is using the ToolTipText property of the UltraGridCell that you mentioned. The only difference is that it will be used inside the InitializeRow event. Each cell could be set with a specific ToolTipText and this tooltip could be based on specific value or any other information that can be obtained from the cells inside the row.
Since you mentioned using dropdowns and dynamically setting the ValueList of the second dropdown and then setting the tooltip based on the first dropdown I am attaching a small sample application that demonstrates how to achieve it with what I have explained above.
Please test the sample on your side and let me know if you have any questions.
Regards, Ivan Kitanov
DependentDropDownCellToolTip.zip
Unfortunately, setting it during InitializeRow doesn't help because the ToolTipText property needs to be set when a dropdown value in a cell is changed.
Do you think setting it on cell MouseOver would work? I can try that and have it detect the first value and set the ToolTipText property according to that. I will post the results when done.
private void gridStudents_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e) { // Generate custom tooltip if (e.Element.GetAncestor(typeof(CellUIElement)) != null) { m_tooltipInfo = new UltraToolTipInfo(((CellUIElement)e.Element.GetAncestor(typeof(CellUIElement))).Cell.ToolTipText, Infragistics.Win.ToolTipImage.None, null, Infragistics.Win.DefaultableBoolean.Default); ultraToolTipManager1.SetUltraToolTip(gridStudents, m_tooltipInfo); ultraToolTipManager1.ShowToolTip(gridStudents); } }
If you want, you could achieve this with the MouseHover or MouseEnterElement events and do exactly as you said about obtaining the cell value and setting the tooltip based on it. Similar and maybe an easier approach would be to use the AfterCellUpdate event of the grid and set the tooltip there. The code for it should be similar to the code inside the InitializeRow event from the sample I sent in my previous post with the only difference being is that an if statement should be used to check if the cell is from the column with the dropdown you would like to base the tooltip on.
The code below demonstrates a simple example of using the AfterCellUpdate event to set a tooltip based on the changed value:
private void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e) { UltraGrid grid = (UltraGrid)sender; // Turn off the event to prevent recursion grid.EventManager.SetEnabled(GridEventIds.AfterCelldate, false); try { if (e.Cell.Column.Key == "State") { // If the State is changed, the city is no longer valid, so clear it out. e.Cell.Row.Cells["City"].Value = DBNull.Value; e.Cell.Row.Cells["City"].ToolTipText = "Select a City from " + e.Cell.Text; } } finally { // Re-enabled this event. grid.EventManager.SetEnabled(GridEventIds.AfterCellUpdate, true); } }
Please let me know if you have any questions.
I decided to use AfterCellListCloseUp to catch the first dropdown value in order to set the next cell's ToolTipText property. This works, but I wanted it to come up sooner and have some styling, so I added a UltraToolTipManager and used the MouseEnterElement to set it to the grid.
This is causing the tooltip to display twice, with both styles. The standard cell one and then the nicer tooltip manager one.
I found that after selecting an option from the dropdown in that cell, only the nice ToolTip displays.
If you want to show only the tooltip that comes from the UltraToolTipManager, what I can suggest you is overriding the TipStyleCell property and setting it to TipStyle.Hide, this can be achieved by adding the following line:
ultraGrid1.DisplayLayout.Override.TipStyleCell = TipStyle.Hide;