HomeVb.NetVideo

VB.NET How to Remove Duplicate Values in DataGridView / DataTable

VB.NET for beginner - How to Remove duplicate rows in DataGridView or DataTable vb.net ? bagaimana cara menghapus value yang sama di datagridview atau datatable vb net?

Laravel 5.5 Tutorial : Create Admin Panel using AdminLTE Bootstrap Template in Laravel 5.5
Laravel 5.5 Middleware Tutorial : How to Create Login with Multiple Level Access in laravel 5.5
Laravel 5.5 AJAX Tutorial : Advanced CRUD Operation with Ajax JQuery in Laravel 5.5
VB.NET tutorial for beginner - How to remove duplicate row from datagridview or datatable in Vb.Net? Hello guys, today i'll show you how to make simple applications and work with DataGridView in vb.net. so we will remove a value / data in a datagridview if they are same. we will delete this row If the row in datagridview have a value and same with any value from any row. lets do it.

Read : How to Insert data Into DataGridView from MySql Database?

Cara menghapus Duplicate Row DataGridView VB.NET

Langsung saja, buatlah sebuah project baru dengan nama "RemoveDuplicate" dan pada Form1.vb silahkan design seperti tampilan dibawah ini :

Pada button1 tuliskan seluruh source code berikut :

Source Code Remove Duplicate Rows

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        ' you can add data into DataGridView using DataTable with you Database (MySQL, Sql Server, Ms Access.)
        ' Tutorials Available in Description or see my offical website "www.hc-kr.com"
        ' just dollow step by step

        Dim Data As String() ' declaration data while insert into datagrid
        Data = {TextBox1.Text, TextBox2.Text, TextBox3.Text}
        DataGridView1.Rows.Add(Data) ' add data into DataGridView

        ' do loop trough rows in datagrid from the top
        For a As Integer = 0 To DataGridView1.Rows.Count - 1
            For b As Integer = a + 1 To DataGridView1.Rows.Count - 1
                ' check trough rows in datagrid if have same value
                If DataGridView1.Rows(a).Cells(0).Value = DataGridView1.Rows(b).Cells(0).Value Then

                    ' if same, just give a message
                    MsgBox("Value same, its will delete" & DataGridView1.Rows(a).Cells(0).Value)

                    ' then, remove the row
                    DataGridView1.Rows.Remove(DataGridView1.Rows(a))
                    a -= 1
                End If
            Next
        Next
    End Sub
Setelah selesai, langsung saja di run "F5".

Penjelasan :
Jika kita memberikan input yang sama pada cells(0) datagridview atau dengan id ("Nama") atau dengan kata lain jika memiliki nama lebih dari satu  maka akan ada peringatan sebelum menghapus row paling bawah dari row yang sama. dengan menggunakan perintah Rows.Remove().

Jika masih bingung dengan penjelasan diatas, silahkan lihat video tutorial berikut :

Video Tuotrial How To Remove Duplicate Value DataGridView



Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


COMMENTS

DISQUS
Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,89,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,6,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: VB.NET How to Remove Duplicate Values in DataGridView / DataTable
VB.NET How to Remove Duplicate Values in DataGridView / DataTable
VB.NET for beginner - How to Remove duplicate rows in DataGridView or DataTable vb.net ? bagaimana cara menghapus value yang sama di datagridview atau datatable vb net?
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgec8tE7E6qgrouDAf0Q9Gu32Kmh8VvE6xE2n0HXkhapH9Sv8fTff-sqMe_irFpWGkVQxcbBnV0na8wwBPYkBivPFXk9-gutTPIKmeJ5YfqkFPo7t1-0zd6tr1_asPn01RW4O6z03uYbNQ/s320/remove-duplicate-datagridview-vbnet.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgec8tE7E6qgrouDAf0Q9Gu32Kmh8VvE6xE2n0HXkhapH9Sv8fTff-sqMe_irFpWGkVQxcbBnV0na8wwBPYkBivPFXk9-gutTPIKmeJ5YfqkFPo7t1-0zd6tr1_asPn01RW4O6z03uYbNQ/s72-c/remove-duplicate-datagridview-vbnet.jpg
KODE AJAIB
https://scqq.blogspot.com/2016/05/vbnet-remove-duplicate-values-in-datagridview-datatable.html
https://scqq.blogspot.com/
https://scqq.blogspot.com/
https://scqq.blogspot.com/2016/05/vbnet-remove-duplicate-values-in-datagridview-datatable.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy