Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

ContextMenuStrip in DataGridView - get the current column

$
0
0

Hi!

I try to implement an interactive filter to my DataGridView. So I've created a ContextMenuStrip with to menus "Add Filter" and "Remove Filter". I've assigned this ContextMenuStrip to each HeaderCell of each coulmn. So that the ContextMenuStrip is only shown on the header.

What I now need is at the opening of the ContextMenuStrip on which Column the ContextMenuStrip is displayed. How can I do this?

I've tried the following but this code returns the last active column:

ContextMenuStrip

myMenu = (ContextMenuStrip)((ToolStripMenuItem)sender).GetCurrentParent();
DataGridView gdvFilter = (DataGridView)myMenu.SourceControl;
gdvFilter.CurrentCell.ColumnIndex

Thanks in advance...
Greets Markus


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>