ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2014-12-19 07:51:18

KPS
Member
Registered: 2014-12-19
Posts: 2

Setting ContextMenu

We want to create the context menu (right click on a cell) based on the Tag value of a cell.

We can set the context menu using the following code:

ContextMenuStrip cmsDefault = new System.Windows.Forms.ContextMenuStrip();
cmsDefault.Items.Add("Test", global::TestReoGrid.Properties.Resources.Image1, onTestClick);
reoGridControl1.ContextMenuStrip = cmsDefault;

But now we first want to set the context menu, based on the Tag value of the clicked cell, before showing the context menu.
We have tried to set the context menu in the "SelectionRangeChanged" event but it first shows the context menu before firing the event.

Any ideas on how to solve this problem?

Kind regards

Offline

#2 2014-12-19 08:08:38

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Setting ContextMenu

Hi, seems the SelectionRangeChanged event in mouse down is not invoked, before the next version to fix this problem, please use the following code instead:

// add an event before context menu display
cmsDefault.Opening += cmsDefault_Opening;
void cmsDefault_Opening(object sender, CancelEventArgs e)
{
    // update the menu label to current selection
    this.currentAddressToolStripMenuItem.Text = "Current Selection: " + reoGridControl1.SelectionRange.ToAddress();
}

The menu label shows like 'Current Selection: D1:B4'.
thanks, Jing

Last edited by Jingwood (2014-12-19 08:11:05)

Offline

#3 2014-12-19 08:32:28

KPS
Member
Registered: 2014-12-19
Posts: 2

Re: Setting ContextMenu

Hi Jing,

Thanks for the quick response.
The provided solution works for us smile.

Kind regards

Offline

Board footer

Powered by FluxBB