C# Filter DataGridView Using Textbox + MySQL Database + Source Code

Tutorial belajar C# (C sharp) Indonesia khusus pemula : cara filter data / search functions di datagridview dari textbox dan value database mysql dan download source code C# filter datagrid using datatable

Belajar C# khusus pemula - bagaimana cara mencari data atau filter data di datagridview dari sebuah textbox menggunakan DataTable Class di C sharp? tutorial kali ini kita akan mencoba membuat aplikasi sederhana dimana merupakan lanjutan dari tutorial C# sebelumnya baca : Insert Data Into DataGridView MySQL Database, jadi tutorial ini hanya menambahkan functions untuk memfilter data yang ada didalam datagridview, jika kamu belum bisa membuat koneksi ke database serta menampilkan data di datagridview silahkan lihat tutorial sebelumnya pada link diatas ya.

Langsung saja pada project sebelumnya (FormUtama.cs) tambahkan sebuah textbox sehingga tampilan form tersebut seperti gambar berikut :

C# Filter DataGridView Using Textbox
Setelah itu, lupakan sejenak tentang Form1.cs, silahkan open ClassController.cs dimana kita akan mengubah sedikit baris code berikut :
OdbcConnection con = new OdbcConnection("DSN=java_db;MultipleActiveResultSets=True;");

Karena kita akan mengakses koneksi dari Form1.cs maka ubah menjadi public seperti berikut :
public OdbcConnection con = new OdbcConnection("DSN=java_db;MultipleActiveResultSets=True;");
Jika sudah silahkan kembali ke form1.cs dan klik pada textbox1 > pilih event TextChanged dan tuliskan code berikut :
        private void metroTextBox1_TextChanged(object sender, EventArgs e) {

            // if you want this applications (insert data into datagridview from MySQL database)
            // just follow my previews tutorial
            // http://scqq.blogspot.co.id/2016/05/c-sharp-menampilkan-data-ke-datagridview-database-mysql.html
            // now we will create filter data into datagrid from a textbox

            cc.con.Open();
            OdbcDataAdapter da = new OdbcDataAdapter("SELECT * FROM biodata where nama like '"+ metroTextBox1.Text +"%'",cc.con);
            dt = new DataTable();
            da.Fill(dt);
            metroGrid2.DataSource = dt;
            cc.con.Close();
            // lets try   
        }
Sebelumnya jangan lupa import namespaces ODBC Driver
using System.Data.Odbc;
Jika sudah selesai semuanya coba jalankan dan harusnya sudah berhasil, jika masih bingung dengan penjelasan dari tutorial diatas, silahkan tonton video tutorial berikut :

Video Tutorial Filter Data From a TextBox into GridVIew


jangan lupa share dan comment jika bermanfaat. terima kasih.

Download Source Code  Filter DataGridView Using Textbox.

COMMENTS

Next Recomended


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


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,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,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: C# Filter DataGridView Using Textbox + MySQL Database + Source Code
C# Filter DataGridView Using Textbox + MySQL Database + Source Code
Tutorial belajar C# (C sharp) Indonesia khusus pemula : cara filter data / search functions di datagridview dari textbox dan value database mysql dan download source code C# filter datagrid using datatable
https://4.bp.blogspot.com/-ZbUBtNO4tZU/VzutrKZgcwI/AAAAAAAABsU/hyq6Nsjp8rsJw16OyE6FDz0Ufnt35KR-gCLcB/s320/scqq-filter-datagridview-from-texbox.jpg
https://4.bp.blogspot.com/-ZbUBtNO4tZU/VzutrKZgcwI/AAAAAAAABsU/hyq6Nsjp8rsJw16OyE6FDz0Ufnt35KR-gCLcB/s72-c/scqq-filter-datagridview-from-texbox.jpg
KODE AJAIB
https://www.kodeajaib.com/2016/05/c-filter-datagridview-using-textbox.html
https://www.kodeajaib.com/
https://www.kodeajaib.com/
https://www.kodeajaib.com/2016/05/c-filter-datagridview-using-textbox.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