2 Replies - 2228 Views - Last Post: 29 November 2012 - 03:46 AM Rate Topic: -----

#1 beegee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 20-October 08

from datagrid to textbox

Posted 28 November 2012 - 11:58 PM

i have a datagrid and i am not sure which event to use or how to use it. I want a situation whereby a user clicks or selects an item and it shows in a textbox then i have a button that will delete that item from the database
Is This A Good Question/Topic? 0
  • +

Replies To: from datagrid to textbox

#2 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 20-September 12

Re: from datagrid to textbox

Posted 29 November 2012 - 02:11 AM

Hi,

Use simple DataGridView click event. and use following code

TextBox1.Text= DataGridView1.SlectedRows(o).Item(i).ToString



where i is the index of column of data grid view or the cell which you want to show in TextBox1.

Hope will work...
Was This Post Helpful? 0
  • +
  • -

#3 nilkanthnaik5  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 16
  • Joined: 22-October 12

Re: from datagrid to textbox

Posted 29 November 2012 - 03:46 AM

If e.ColumnIndex > -1 And e.RowIndex > -1 Then
TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
End If




Write above code in DataGridView CellClick Event.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1