Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,097 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,834 people online right now. Registration is fast and FREE... Join Now!




Delete row from DataGridView

 
Reply to this topicStart new topic

Delete row from DataGridView

jleen
22 Apr, 2008 - 07:35 PM
Post #1

New D.I.C Head
*

Joined: 12 Mar, 2008
Posts: 8

i have been searching for help on how 2 deleted the selected row in a gridview but have to found anything that could help me.
is it not possible to do it using VB codes ?
every search result i get is for ASP.net
pls help me out on this
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Delete Row From DataGridView
22 Apr, 2008 - 08:09 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
I am moving this question into its own topic, as it does not belong in the tutorial requests.

To answer your question, you select the entire row by clicking the header on the right of the DataGridView.

Then you can use the following code to remove a row(s) from the control. You can select more than one row for deletion at a time.
CODE

// remove all rows selected
foreach (DataGridViewRow dr in DataGridView1.SelectedRows)
{
    if (DataGridView1.Rows.Count > 1)
        DataGridView1.Rows.Remove(dr);
}

User is offlineProfile CardPM
+Quote Post

jleen
RE: Delete Row From DataGridView
22 Apr, 2008 - 10:45 PM
Post #3

New D.I.C Head
*

Joined: 12 Mar, 2008
Posts: 8

thanks alot jayman9 for ur help ,
but there is no .remove command for the gridview1
i am currently using Visual Studio 2005.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Delete Row From DataGridView
23 Apr, 2008 - 07:47 AM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Hmm...I don't have any GridView controls for a Windows form.

Are you perhaps referring to a DataGrid??
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:22AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month