Hi!
I've combined zero or more bitmaps together (based on data retrieved from a database) to form one bitmap. This new combined bitmap is then set as the image for a column in the grid:
Bitmap dwpBitmap = ConstructDWPBitmap(dwpList, out typeListString, DWPType2BitmapList); if (dwpBitmap != null) { detailsCell.ButtonAppearance.Image = dwpBitmap;
ConstructDWPBitmap is losely based on this really nice article your company wrote:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=6018
When the user clicks on the button with this image I want to know which image they clicked on. To save space I don't want to have to form multiple columns to house each bitmap separately. How can I know which image the user clicked on so I can take the appropriate action?
I can't seem to find the X,Y location of the click event in that button. Any suggestions are appreciated.
Thanks!
Craig
Hi Craig,
Click events don't typically expose a location. So what you could do is use the MouseDown event and store the location in a form-level member variable, then use that location in the CellButtonClick event.
Outstanding Mike! I'll give it a go and let you know how it goes.
Thank you for the fast response!
Hello Craig,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
Hi Boris,
I'm still working through some of the details. I'll let you know.
Thanks you for checking in!
I just looked at my code again and I realized, I forgot something. You should add a check to make sure element is an ImageUIElement. If it's not, then it means they clicked on some other part of the cell.
Point lastMouseDownPoint; void ultraGrid1_MouseDown(object sender, MouseEventArgs e) { lastMouseDownPoint = e.Location; } void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e) { UltraGrid grid = (UltraGrid)sender; ImageUIElement element = grid.DisplayLayout.UIElement.ElementFromPoint(this.lastMouseDownPoint) as ImageUIElement; if (null == element) return; Point p = new Point( this.lastMouseDownPoint.X - element.Rect.X, this.lastMouseDownPoint.Y - element.Rect.Y); Debug.WriteLine(string.Format("Image clicked at :{0}", p)); }
Great. Thank you for the follow up Mike.
I'm having problems getting the ClickCell event to fire for my grid. The MouseDown event is firing fine but not the ClickCell. Other than using reflection I haven't found a way to examine what delegates are attached to the grid's ClickCell event.
A graphical summary of properties using icons, rather than multiple columns of text or icons, seems like something that would be common. Are there plans for a column type for this? Or perhaps I'm overestimating either the use or the complexity?
Hm. I can't think of any reason why the ClickCell event would not fire. Unless, of course, you are not clicking on a cell. Or maybe you are using a really old version of the grid that had a bug in it.
Regarding the use case, if you need a cell with multiple buttons in it that display images, I think I would use Editor buttons instead of trying to hit-test on an image. It's a lot less work and it also displays as buttons so the user knows they are UI-active.
What you do is create an editor control like UltraTextEditor. Use the ButtonsLeft or ButtonsRight collection to add whatever buttons you want in the cell and apply an Appearance to each button - including an image if you like.
Then you set the column's EditorControl to the UltraTextEditor control and handle the UltraTextEditor's EditorButtonClick event. The event gives you an 'e.Context' which will return the grid cell that was clicked and also the button that was clicked.