Click here to Skip to main content
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 19-Dec-10 0:20am
Edited 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. 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 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 195
3 DamithSL 195
4 Richard MacCutchan 178
0 OriginalGriff 5,130
1 DamithSL 4,197
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 21 Dec 2010
Copyright © CodeProject, 1999-2014
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