Anyone,
I'm trying to add a tooltip to my ultragrid when the user hovers over a cell. My first step was to just get the tooltip to display when the user was over a cell and then I was going to check for a specific cell in the next step. I can't get the following code to work to display the cell. I have the ultraToolTipManager on the form.
My code is below. Thanks, Kris
{
// Get the cell location.
// Get a refernce to the cell.
// Make sure the mouse is over a cell.
new Infragistics.Win.UltraWinToolTip.UltraToolTipInfo("Click Button", ToolTipImage.Info, "Delete Record", DefaultableBoolean.True);
// Display the tooltip.
ultraToolTipManager.SetUltraToolTip(igrdAgentPool, tipInfo);
ultraToolTipManager.ShowToolTip(igrdAgentPool);
}
else
ultraToolTipManager.HideToolTip();
Hi Allen,
allenovereem said:What I'm trying to do is store one value in a cell and another value in the tool tip for that cell.
I'm getting even more confused. You seem to be contradicting yourself here.If all you want to do is display a tooltip in a cell that is different from the actual text in the cell, then you just set the ToolTipText on the cell. You can do this in InitializeRow. It's very simple.
But you seem to say quite clearly in your previous post that this is not all you need to do. You said that you also want to change the actual value of the cell in addition to the tooltip. That's where I think you will run into problems.
allenovereem said:Are you saying there is no way to set the value of the cell from the initializerow event?
No, I am not saying that. But if you set the Value of a cell in InitializeRow, or any other event, you lose the original Value of the cell. If the value in a cell is "123", and you change that value to "321", then the next time InitializeRow fires, you will get "321". It doesn't make sense to change the value of the cell and lose the original value, because then you will end up processing the new value and change the cell's value and tooltip again.
Are you under the impression that InitalizeRow only fires once for each row? Because that is not the case. InitializeRow will fire any time any value in the row changes, when the row is first creating, and may fire when the grid gets certain notifications from the data source.
Hi Mike. Thanks for the response. I'm sure I'm not following you. :-)
What I'm trying to do is store one value in a cell and another value in the tool tip for that cell. These values are known at the time the grid is filled so initializerow will only be fired while the values are known. If the grid is reloaded then the stored procedure will be called again and the values may be different from the last time the grid was filled but that will again be known when initializerow is called.
The two values for each cell are different than the values of any of the other cells in a particular column and the two values for a particular cell are not related to each other except that they are part of the same row from the result set which is being processed as the rows are being added to the grid. Columns have already been created and added to the grid before the rows are added.
Are you saying there is no way to set the value of the cell from the initializerow event?
Are you saying that I need to create an unbound column for every column in the grid and basically to have two cells for each cell and then somehow grab the value from the cell in the unbound column to display in the tool tip on hover over the cell in the bound column?
Thanks again.
Allen
I'm not sure I am following what you are trying to do here. If you set the value on the cell to something other than the original key value, then you will lose the key value and the next time InitializeRow fires, it won't be there.So that doesn't seem like a good idea.
If you have a key value in a cell and you want to show something else and also have a tooltip with different information, then what I would do is hide the key column and add an unbound column to the grid.
Then you use InitializeRow to set the value and the ToolTipText on the unbound column based on the value of the key column. That way you don't lose the key value and can still display 2 different pieces of information based on that key.
Hey Mike,
I am still trying to figure out the cleanest way to be able to display both of my values - the one that needs to appear in the cell and the one that needs to appear in the tool tip on hover. I thought I could store the key they both share in the value and then replace the value at row initialization time but I'm getting an error that seems to indicate I cannot update the cell value because the column is read-only. I thought maybe the issue was me trying to pass a string value to the cell's SetValue which takes an object so I changed that to cast the string as an object but that doesn't help matters any. What am I doing wrong? Can I not update the cell value at time of row initialization?
Thanks.
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { for (int cellCounter = 0; cellCounter < e.Row.Cells.Count; cellCounter++) { string tempGuid = e.Row.Cells[cellCounter].Value.ToString(); int thisIndex = HoverTextsList.IndexOf(tempGuid) + 1; if (thisIndex > 0) { e.Row.Cells[cellCounter].ToolTipText = HoverTextsList[thisIndex]; e.Row.Cells[cellCounter].SetValue((object)ValueTextsList[thisIndex],false); } } }
System.Data.ReadOnlyException: Column '08/12/2009' is read only. at System.Data.DataRow.set_Item(DataColumn column, Object value) at System.Data.DataRowView.SetColumnValue(DataColumn column, Object value) at System.Data.DataColumnPropertyDescriptor.SetValue(Object component, Object value) at Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(UltraGridColumn column, Object val, Boolean suppressErrorMessagePrompt, Boolean throwExceptionOnError, Boolean fireDataChanged, Boolean fireCellUpdateEvents) at Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(UltraGridColumn column, Object val, Boolean suppressErrorMessagePrompt, Boolean throwExceptionOnError, Boolean fireDataChanged) at Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(UltraGridColumn column, Object val, Boolean suppressErrorMessagePrompt, Boolean throwExceptionOnError) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(Object value, Boolean suppressErrorMessagePrompt, Boolean fireInitializeRow, Boolean throwExceptionOnError, Boolean fireDataChanged) at Infragistics.Win.UltraWinGrid.UltraGridCell.set_Value(Object value) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValue(Object value, Boolean storeInUndoStatck, Boolean checkForReadOnlyCells) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValue(Object value, Boolean storeInUndoStatck) at CTCAFlowsheetTab.frmCTCAFlowsheetTab.ultraGrid1_InitializeRow(Object sender, InitializeRowEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.OnInitializeRow(InitializeRowEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireInitializeRow(InitializeRowEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGridRow.FireInitializeRow() at Infragistics.Win.UltraWinGrid.RowsCollection.FireInitializeRow(IList rows) at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRowsHelper(IList boundList) at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRows() at Infragistics.Win.UltraWinGrid.RowsCollection.EnsureNotDirty() at Infragistics.Win.UltraWinGrid.RowsCollection.GetEnumerator() at CTCAFlowsheetTab.frmCTCAFlowsheetTab.FillGrid(String storedProcName)
Mike,
Nevermind the last question there. I did this and removed the logic to track the mouse move, etc. and it shows the tool tip on hover beautifully.
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { for (int cellCounter = 0; cellCounter < e.Row.Cells.Count; cellCounter++) { e.Row.Cells[cellCounter].ToolTipText = e.Row.Cells[cellCounter].Value.ToString(); } }
ow if I can just get the other value populated I'll be able to get back to bothering you about how to sort the group by rows in other than alphabetical order!
Thanks much!