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.
Unfortunately, activation email could not send to your email. Please try again.

Determining Cell Image click?

Thread ID:





1327 Oct 17,2002 09:55 PM Oct 21,2002 01:39 AM Windows Forms 2
Tags: GridControl
Kai Iske
Asked On October 17, 2002 09:55 PM

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

Stefan Hoenig [Syncfusion]
Replied On October 18, 2002 06:57 AM

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

Kai Iske
Replied On October 21, 2002 01:39 AM

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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.