Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2003, 12:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Datagrid Control

Hello,

Does anybody know how to remove a row from the data grid control? I can't figure it out.

Thanks.
__________________
Brian
 
Old November 17th, 2003, 02:10 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In the DataGrid web control, there is a collection of "Items" from which you could add or remove items. However it seems that there isn't such a beast on the windows forms DataGrid. It looks as though you need to remove the row/item from your datasource before you bind the grid to it.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 20th, 2003, 08:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Ok, say you want to remove a row from the data source. How can you figure out which row to delete, when a row is clicked on? Is there a way to get the ID parameter from the data grid, or do you base it off of the index number?
 
Old November 20th, 2003, 12:49 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

(Again, disclaiming that my knowledge is based only on working with the webcontrol datagrid...)

The datagrid control contains an event for selecting, editing, updating, deleting rows. The signature for that event has an event arg object that contains an Item object which corresponds to the datagrid row item that you are performing the operation on. You can get the index of that item (...Item.ItemIndex), but in most cases you just care about what's actually IN the item (i.e. the cells/columns of the datagrid). With that, you can extract the particular bits of data you need to perform the designated operation.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
datagrid control sandeep ADO.NET 2 February 9th, 2004 10:54 AM
Urgent: Other control in Datagrid mrleokarthik Pro VB 6 0 November 27th, 2003 01:30 AM
DataGrid Control mike123abc Beginning VB 6 0 November 18th, 2003 04:24 AM
DataGrid Control cej2583 VB How-To 0 August 7th, 2003 02:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.