search - Searching In datagridview in Windows Application VB.NET -
i have filter datagridview using textbox.the code below using fill gridview.getdata function of db class returns datatable.
i not using datasource property of gridview instead filing gridview using loop.
i can searching using datasource property , dataview have not fill datagridview directly datasource property.
sub griddesgn() datagridview1.columns.clear() datagridview1.rows.clear() datagridview1.columns.add("crime", "crime") datagridview1.columns.add("actname", "actname") datagridview1.columns.add("section", "section") datagridview1.columns.add("description", "description") end sub private sub test_load(byval sender object, byval e system.eventargs) handles me.load griddesgn() dim dbobj new db dim dtt datatable = dbobj.getdata("select crime,actname,section,description natureofcomplaint_women") if dtt.rows.count > 0 integer = 0 dtt.rows.count - 1 datagridview1.rows.add() datagridview1.rows(i).cells("crime").value = dtt.rows(i).item("crime") & "" datagridview1.rows(i).cells("actname").value = dtt.rows(i).item("actname") & "" datagridview1.rows(i).cells("section").value = dtt.rows(i).item("section") & "" datagridview1.rows(i).cells("description").value = dtt.rows(i).item("description") & "" next end if end sub
use statement in sql query
"select crime,actname,section,description natureofcomplaint_women crime = " & txtsearch.text
(if want search on crime.) change needs. repeat datagrid fill used above, altereted sql query each time type/press search button
Comments
Post a Comment