Click here to Skip to main content
11,640,445 members (62,986 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB8.0
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 18-Dec-10 23:20pm
Edited 18-Dec-10 23:30pm
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. Smile | :)

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 Smile | :)
  Permalink  

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

  Print Answers RSS
0 Mika Wendelius 300
1 CPallini 209
2 OriginalGriff 165
3 Sergey Alexandrovich Kryukov 139
4 Afzaal Ahmad Zeeshan 130
0 Mika Wendelius 200
1 OriginalGriff 145
2 CPallini 115
3 jgakenhe 40
4 sasanka sekhar panda 30


Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 21 Dec 2010
Copyright © CodeProject, 1999-2015
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