PC Review


Reply
Thread Tools Rate Thread

Delete row from DataGrid via code

 
 
=?Utf-8?B?amdyaW1zbWFu?=
Guest
Posts: n/a
 
      12th Jul 2004
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
 
Reply With Quote
 
 
 
 
Richard Myers
Guest
Posts: n/a
 
      12th Jul 2004
Hi Jason

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

hth
Richard


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      12th Jul 2004
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


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      12th Jul 2004
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


 
Reply With Quote
 
Richard Myers
Guest
Posts: n/a
 
      12th Jul 2004
Yep.. or just use the value of cm.current before you removeat.
Depends on what your doing Jason.

Richard


 
Reply With Quote
 
=?Utf-8?B?amdyaW1zbWFu?=
Guest
Posts: n/a
 
      14th Jul 2004
Thanks guys.

I actually ended up doing:

Me.DataGridView1.Rows.Remove(Me.DataGridView1.SelectedRows(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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete data in a linked Excel sheet using Access code or seql delete Rocky Microsoft Access External Data 9 26th Jun 2005 12:42 AM
code to delete a user/ code to move users into and out of groups =?Utf-8?B?dHc=?= Microsoft Access Security 11 30th May 2005 06:59 AM
Delete Event when pressing delete in a datagrid? Lars Netzel Microsoft VB .NET 2 20th Jan 2005 02:38 PM
Delete mutiple rows in a dataGrid using delete Key =?Utf-8?B?TVZC?= Microsoft Dot NET Framework 0 26th Oct 2004 04:39 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Microsoft Excel Programming 0 27th Jan 2004 07:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 PM.