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.

Changing cell contents at context menu location

Thread ID:

Created:

Updated:

Platform:

Replies:

16140 Jul 6,2004 05:53 PM Jul 7,2004 02:31 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 6, 2004 05:53 PM

Hi, I''m using a context menu on the grid control. I want an option of the context menu to allow the user to highlight the text in the cell under the context menu. I''ve followed the sample "CellCommentTips" that allows the user to paint an Excel like triangle in the top right hand corner of the grid using grid_CellDrawn and e.Graphics.FillPolygon. I have the context menu working properly. Can anyone tell me how to get a reference to the cell itself and change it''s background colour, or change the colour of the text in that cell please? Thanks.

Administrator [Syncfusion]
Replied On July 6, 2004 06:37 PM

What kind of grid are you using? If it is a GridDataBoundGrid, you cannot ''set'' the style properties of a single cell. Instead, you handle an event, and dynamically provide the style properties for the requested row and column. http://www.syncfusion.com/Support/article.aspx?id=560 So, in your context menu, you could set some Form variables to save the right-clicked cell''s row and col. Then in PrepareViewStyleInfo, you would test e.ColIndex and e.RowIndex to see if they matched the saved row and col of teh context menu. If they do, then you can set e.Style.BackColor and e.Style.TextColor to try to change the cell.

Administrator [Syncfusion]
Replied On July 7, 2004 01:50 AM

Sorry I should have specified - it''s the Syncfusion.Windows.Forms.Grid.GridControl.

Administrator [Syncfusion]
Replied On July 7, 2004 02:31 AM

Here is a little sample. It handles 2 sort of complications. One regards when the grid''s comtext menu is displayed versus when a cell control''s context menu is displayed. The sample does a little work to make both cases display the same menu. The other is a problem getting the row, col of the click. For some reason, Control.MousePosition is not working for me to get the proper right click (I suspect the Framework is tweaking this to display its popup). But this problem can be worked around by handling CurrentCellMoved and just tracking the focusRow and focusCol. (Depending on setting, you may need to add a grid.MouseDown handler to track this as well. The sampledoes not need this.) ContextMenu_7384.zip

CONFIRMATION

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.

;