3 Replies - 19433 Views - Last Post: 26 July 2009 - 11:48 PM Rate Topic: -----

#1 kayatri  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 216
  • Joined: 05-May 09

Delete the selected row from datagridview

Posted 26 July 2009 - 06:11 PM

I have a data which is saved in textfile. when form load the data in text file will be load in datagridview. i want delete the selected row from the datagridview. I used this coding to delete.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

 Dim row As Integer
	Public selRow As New DataGridViewRow
		Dim index As Integer
		index = DataGridView1.SelectedRows.Item(0).Index 
		selRow = DataGridView1.Rows.Item(index) 
		DataGridView1.Rows.Remove(selRow) 
		row = row - 1 

   End Sub


When i exucute this code it shows me error

"Rows cannot be programmatically removed unless the datagridview is data-bound to an IBindingList that support change notification and allows deletion."

I dont understand what is this error and how to solve this?

Is This A Good Question/Topic? 0
  • +

Replies To: Delete the selected row from datagridview

#2 kimanipatrick  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-June 09

Re: Delete the selected row from datagridview

Posted 26 July 2009 - 06:45 PM

Honestly these

(Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim row As Integer
Public selRow As New DataGridViewRow
Dim index As Integer
index = DataGridView1.SelectedRows.Item(0).Index
selRow = DataGridView1.Rows.Item(index)
DataGridView1.Rows.Remove(selRow)
row = row - 1

End Sub
)

code is working but when you navigate away from the compile mode the data is still there in the database table. what code should i add to update the action in the database table?
Was This Post Helpful? 0
  • +
  • -

#3 kayatri  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 216
  • Joined: 05-May 09

Re: Delete the selected row from datagridview

Posted 26 July 2009 - 07:02 PM

View Postkimanipatrick, on 26 Jul, 2009 - 05:45 PM, said:

Honestly these

(Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim row As Integer
Public selRow As New DataGridViewRow
Dim index As Integer
index = DataGridView1.SelectedRows.Item(0).Index
selRow = DataGridView1.Rows.Item(index)
DataGridView1.Rows.Remove(selRow)
row = row - 1

End Sub
)

code is working but when you navigate away from the compile mode the data is still there in the database table. what code should i add to update the action in the database table?






i dont understand ur question. When i delete from datagridview i also want to delete from my textfile where i save my datagridview value in my text file
Was This Post Helpful? 0
  • +
  • -

#4 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: Delete the selected row from datagridview

Posted 26 July 2009 - 11:48 PM

Please :code:, and please dont use excess font size when posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1