Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi all,

I have one DataGridView with 5 columns. My requirement is that, when i select a row in grid and click on button(send)I need the value in the 3rd column in to a text box and the column contain data of data type string. Anyone could help me ASAP.
Thanks in Advance.

Anish
Posted 20-Nov-12 6:07am
Edited 20-Nov-12 6:21am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this..................

on
 
dataGridView1_CellDoubleClick
Textbox1.text = dataGridView1[e.ColumnIndex, e.RowIndex].Value;
  Permalink  
v2
Comments
Anish612 at 21-Nov-12 4:43am
   
Thanks for the quick solution
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

dataGridView1.CurrentRow.Cells[0].Value

it will give you value of selected row's 0. cell.
  Permalink  
v3
Comments
Anish612 at 21-Nov-12 4:41am
   
That make sense. Thanks for your time
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try this one...

you want to fist select the row you want to send data and then click the "Send" button and send data? right?

so you can do something like this..

for the CellContentClick event of datagridview add this code (make sure to declare
int RowNo;
outside the event..then you can refer it from the button click event)

 RowNo = e.RowIndex;

for the button click event

 string Value = dataGridView1.Rows[RowNo].Cells[2].Value.ToString();

instead of giving Cells[2] you can give column name that you have given inside " "

Happy coding....
  Permalink  
Comments
Anish612 at 21-Nov-12 4:42am
   
Thanks for the effort
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

klkknnnnnnnnnnnnnnnnnnnnnnnnnnnn
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 408
1 Sascha Lefévre 235
2 Maciej Los 180
3 Abhinav S 170
4 Richard Deeming 155
0 Sergey Alexandrovich Kryukov 7,096
1 OriginalGriff 6,395
2 Maciej Los 2,782
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 14 Nov 2013
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