How to get the value from a row in DataGridview using KeyDown Method

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a DataGridview which binded TO a Datatable in a Windows Form, and Declared the code below in the Constructor
<span style="font-size:small -----------------------------------------------------------------------------------------
<span style="line-height:115%; font-family:Courier New; font-size:8pt ATMRdg1.KeyDown +=<span style="color:blue new
<span style="color:#2b91af KeyEventHandler(ATMRdg1_KeyDown);
<span style="font-size:small -----------------------------------------------------------------------------------------
<span style="line-height:115%; font-family:Courier New; font-size:8pt <span style="line-height:115%; font-size:8pt so basically I have this method inside my code<br/>

<span style="font-size:small -----------------------------------------------------------------------------------------
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Courier New; font-size:8pt protected<span style="font-family:Courier New; font-size:8pt
<span style="color:blue void ATMRdg1_KeyDown(<span style="color:blue object
sender, System.Windows.Forms.<span style="color:#2b91af KeyEventArgs e)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt {
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt <span> <span style="color:blue if(e.KeyCode ==
<span style="color:#2b91af Keys.F2)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt {
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt }
<span style="line-height:115%; font-family:Courier New; font-size:8pt }
<span style="font-size:small -----------------------------------------------------------------------------------------
<span style="font-size:small So what Im hoping to accomplish is, how do I get the value when I press F2... for example, if the Mouse coursor is in a row which contains a value of
F3194 and when I press F2 button... how do I get that value " F3194 <span style="font-size:small "??
<span style="font-size:small
<img alt="" src="http://i1197.photobucket.com/albums/aa427/jayobina/keydown.png

<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Courier New; font-size:8pt protected<span style="font-family:Courier New; font-size:8pt
<span style="color:blue void ATMRdg1_KeyDown(<span style="color:blue object
sender, System.Windows.Forms.<span style="color:#2b91af KeyEventArgs e)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt {
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt <span>
<span style="color:blue if(e.KeyCode == <span style="color:#2b91af
Keys.F2)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt {
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt

<span style="color:red; line-height:115%; font-family:Courier New; font-size:8pt Get the value "F3194" from the DataGridview as shown in the Picture
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:8pt }
<span style="line-height:115%; font-family:Courier New; font-size:8pt }

View the full article
 
Back
Top