4 Replies - 27922 Views - Last Post: 30 August 2009 - 06:49 AM Rate Topic: -----

#1 greg55447  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-August 09

how to get data from datagridview row in the text boxes

Post icon  Posted 28 August 2009 - 12:38 PM

Help!
Is This A Good Question/Topic? 0
  • +

Replies To: how to get data from datagridview row in the text boxes

#2 bodom658  Icon User is offline

  • Villiage Idiom
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,123
  • Joined: 22-February 08

Re: how to get data from datagridview row in the text boxes

Posted 28 August 2009 - 01:36 PM

Acess the value of the cell using datagridView1.Rows[I].Cells[I].Value

For future reference,

[Rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 greg55447  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-August 09

Re: how to get data from datagridview row in the text boxes

Posted 28 August 2009 - 01:58 PM

View Postgreg55447, on 28 Aug, 2009 - 11:38 AM, said:

Help!

Thank you, but I am a beginner and I have know idea what code do I need to use for this. I tried your code and it didn't work. What event do I need to use for this code?
Was This Post Helpful? 0
  • +
  • -

#4 dhanavelraj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 15-June 09

Re: how to get data from datagridview row in the text boxes

Posted 30 August 2009 - 01:15 AM

View Postgreg55447, on 28 Aug, 2009 - 12:58 PM, said:

View Postgreg55447, on 28 Aug, 2009 - 11:38 AM, said:

Help!

Thank you, but I am a beginner and I have know idea what code do I need to use for this. I tried your code and it didn't work. What event do I need to use for this code?



I think this is correct code for get the data from datagridview ,here code

textbox1.text=datagridview1.Rows[i].Cells[i].Value;

:^:
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: how to get data from datagridview row in the text boxes

Posted 30 August 2009 - 06:49 AM

try this instead...

"rowNumber" is the number of the row that you want to get the value for. Remember that it is 0-based, so the first row would be 0, the second row would be 1, etc.

"columnNumber" is the number of the column that you want to get the value out of. Remember this is also 0-based.

example:

int rowNumber = 0;
int columnNumber = 0;

textbox1.Text = dataGridView1.Rows[rowNumber].Cells[columnNumber].Value;



also, replace "textbox1" with the actual name of your textbox. Replace "dataGridView1" with the actual name of your gridview.

In the example, it will take the value from the first column of the first row.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1