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

Determining Cell Image click?

Thread ID:





1327 Oct 18,2002 01:55 AM UTC Oct 21,2002 05:39 AM UTC WinForms 2
Tags: GridControl
Kai Iske
Asked On October 18, 2002 01:55 AM UTC

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 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

Kai Iske
Replied On October 21, 2002 05:39 AM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon