Click here to Skip to main content
13,258,269 members (39,030 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I created some datagridview and their ContextMenuStrip by code.
There are many options in ContextMenuStrip.
I need the following:
1- Identify the datagridview I clicked on when the ContextMenuStrip item is selected.
2- or return the row information after selecting ContextMenuStrip item.
Posted 19-Dec-10 0:20am
Updated 19-Dec-10 0:30am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

To help with your first problem Getting the control that called a context menu[^]

I am not sure that I understand your second part. 'return' to where? perhaps you could expand that a little to make your question clearer.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

tank you for your answer
and i main in the seconed part
after i select an item from the ContextMenuStrip i need to determaine which row or select the row that clicked on
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

thanx for all
i found the solution
part 1:
use SourceControl proprity for ContextMenuStrip which return the last control of the ContextMenuStrip

part2:
determin the rowindex using mousedown event on the datagridview
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

For your second part DataGridView has a CurrentRow[^] property. You'll never guess what it returns. :)

I am not sure whether it will solve your problem as, without checking, I do not know if it gets set for a right click. Still check it out, it might do the trick.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

for Your second Question you can do this step

Me.Datagrid.CurrentRow.Cells.Item(0).Value.ToString

This code shows you which row selected and you can put 0 to length of your columns to manage which of column you want to return data

and you can use this code for Just Know About which of rows was Selected
Me.Datagrid.CurrentRow :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 21 Dec 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100