We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Determining Cell Image click?

Is there a way to determine that the user has clicked on a cell's image? Also, a nice thing to have would be to be able to supply some positioning information for the image as with the standard MS Label control, maybe. Regards Kai Iske

2 Replies

SH Stefan Hoenig Syncfusion Team October 18, 2002 10:57 AM UTC

Hi Kay, thanks for the suggestion. We'll add such a property. We'll also add a ImageClicked event to make it easier to detect a click on the image. Here is what you can do now: [C#] protected override void OnCellClick(GridCellClickEventArgs e) { GridControlBase grid = this; Point pt = new Point(e.MouseEventArgs.X, e.MouseEventArgs.Y); GridStyleInfo style = grid.Model[e.RowIndex, e.ColIndex]; GridCellRendererBase renderer = grid.CellRenderers[style.CellType]; GridCellLayout layout = renderer.GetCellLayout(e.RowIndex, e.ColIndex, style); bool clickedOnImage = (!layout.TextRectangle.Contains(pt) && layout.ClientRectangle.Contains(pt)); if (clickedOnImage) { MessageBox.Show(" Clicked on bitmap "); } else base.OnCellClick(e); } [VB] protected override void OnCellClick(GridCellClickEventArgs e) { Dim grid As GridControlBase = Me Dim pt As Point = New Point(e.MouseEventArgs.X,e.MouseEventArgs.Y) Dim style As GridStyleInfo = grid.Model(e.RowIndex,e.ColIndex) Dim renderer As GridCellRendererBase = grid.CellRenderers(style.CellType) Dim layout As GridCellLayout = renderer.GetCellLayout(e.RowIndex,e.ColIndex,style) Dim s As String = "" Dim clickedOnImage As Boolean = (Not lay.TextRectangle.Contains(pt) And lay.ClientRectangle.Contains(pt)) if (clickedOnImage) { MessageBox.Show(" Clicked on bitmap ") } else MyBase.OnCellClick(e) } Stefan


KI Kai Iske October 21, 2002 05:39 AM UTC

Thanks Stefan, that solves it for now. Regards Kai Iske

Loader.
Up arrow icon