Hi,
I'm looking to create functionality similar to that seen in Excel where you can add notes/comments onto a cell and you get the little red triangle in the top corner of the cell.
Is this kind of thing possible with the WinGrid?
If so, any pointers to get me going please?
Thanks
Alan
Hi Alan,
So the idea is to present a context menu with an option to insert a comment to an UltraGridCell and supplying a UI for that input. When that input disappears you render an image on that cell. I went about that far with this example. You also need to do the editing of the comment and the deletion of the comment. This example is still a little finicky and will not always render the image for me but it should be plenty to get you started on this task.
1. Run the application.
2. Right click on a cell and select Insert Comment from the context menu.
3. Enter some text in the text editor that appears.
4. Click off the input text box for the comment.
5. Repeat these steps for another cell.
6. The finicky portion... click on a row selector and then off to see the image show up sometimes.
Note: you can do a lot more with the input UI... I just used a PopupControlContainer and an UltraTextEditor with Multiline = true. Also note that Edit TextBox will end up covering some but not all of the image rendered when there is a comment. You would have to adjust the rect of the ImageUIElement to sneak in a bit or hide it or do something there. I also did not have the comment show up when you mouse over the cell or the image but that should be trivial if you get this far.
P.S. - The image is added via a CreationFilter on the UltraGrid control.
Happy Coding.
I do not have any experience writing tooltip. I want one tooltip when user is over the red triangle image while another tooltip when mouse is over rest of the cell. Is that possible? How complex is it?
Thanks!
This is possible. You can test to see which UI Element the mouse is over and determine which tooltip to show by that criteria. If you want to see some examples of using the TooltipManager take a peek at the WinForms Samples Browser and go to UX Enhancers and view the three WinToolTipManager samples.
As far as complexity goes it is fairly complex. If you have no experience working with UI Elements and the TooltipManager it will be more complex than if you have previously worked with them.
For both of your requests you could also use the WinToolTipManager and call the ShowToolTip method based upon the UI Element being interacted with via the mouse. Again, see the UX Enhancers -> WinToolTipManager examples in the WinForms samples browser for guidance.