Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine Right-Click, Paste In TextBox
Message
De
28/04/2010 16:22:11
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01460845
Message ID:
01462392
Vues:
28
>I already tried. The default context menu pops up.

Ooops, my bad. I have a test application where I test all kinds of stuff. I saw somewhere in that app where I was setting the Grid's ContextMenu, as I mentioned. I assumed that was what was making it work. After a bit more digging, I see I was wrong. You need to handle the Grid's CellMouseDown event like so:
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
	if (e.Button == MouseButtons.Right)
	{
		this.dataGridView1.CurrentCell = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
		this.oContextMenu.Show(this.dataGridView1, new Point(e.RowIndex, e.ColumnIndex));
	}

}
That should do the trick. Sorry about that!!!

~~Bonnie



>>>I retract that... The user will be right-clicking and pasting into a DataGridView cell in a WinForms app. Right now, the standard, default
>>>context menu pops up. I don't see any way to trap it.

>>
>>If you want a custom ContextMenu, all you have to do is set the Grid's ContextMenu like this:
>>
>>MyGrid.ContextMenu = this.MyCustomContextMenu;
>>
>>Does that help at all?
>>
>>~~Bonnie
>
>I already tried. The default context menu pops up.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform