By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Delete row from DataGrid via code

P: n/a
If a user clicks on a row in a data grid, I would like them to be able to click a button and delete that row. I can't seem to figure out how to go about doing that. Can anyone help?

Thanks in advance,

Jason
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Jason

dim cm as CurrencyManager
cm = Me.BindingContext(me.dgMyDataGrid.Datasource)
if not cm is nothing then cm.RemoveAt(cm.current)

hth
Richard
Nov 20 '05 #2

P: n/a
Hi Richard,

I think that you seldom will use the removeAt It. It removes the data from
the dataset and makes it impossible to do an update.

Use the datarow.delete instead

http://msdn.microsoft.com/library/de...oveattopic.asp

Because what I sais is not mentioned above, I am not completly sure however
read below about the datarowcollection.removeAt what I think is done with
the currencymanager.removeAt

http://msdn.microsoft.com/library/de...oveAtTopic.asp

I hope this helps?

Cor
Nov 20 '05 #3

P: n/a
Hi Jason,

I made a sample in the weekend for Agnes and Manuel. It is about a listbox
however when you change that for datagrid it works in my opinion as well.

http://groups.google.com/groups?hl=e...TNGP12.phx.gbl

I hope this helps?

Cor
Nov 20 '05 #4

P: n/a
Yep.. or just use the value of cm.current before you removeat.
Depends on what your doing Jason.

Richard
Nov 20 '05 #5

P: n/a
Thanks guys.

I actually ended up doing:

Me.DataGridView1.Rows.Remove(Me.DataGridView1.Sele ctedRows(0))

and then sending the update command to the datatableadapter

Thanks again,

Jason

"Richard Myers" wrote:
Yep.. or just use the value of cm.current before you removeat.
Depends on what your doing Jason.

Richard

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.