seach on Grid

Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
I want to apply search on my datagrid

hye i m a beginner og vb.net ,I ve a text box i want if i write a string in textbox automatically my grid should be on correceponding record I know its a small qus plz help me if u can i ll be thankful to u


prashant
 
Hi,
U can try this..............
1>Bind ur datagrid's datasource with Datables' Default view..........
2>on text changed event of the text box where u r tying search string write this...

datagrid.datasource.rowfilter = " Searchcolumn like '" & txtSearch.text.trim & "%'"

I hope this will help u...................

Regards,
Ritesh
 
thanx for suggestion but when i use this statement then it gives me error public member 'rowfilter' on type 'datatable' not found

plz give me the solution if u can , if u hve tried it then u can give me the solution plz try i ll be very thkful to u
 
Last edited:
Hi,
what's the Datasource of ur Datagrid.?...................i assume it is

datagrid.datasource = table.defaultview..............


Regards,
Ritesh
 
Private Sub frmDataGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'SqlDataAdapter1.Fill(Grdtst1)

ds = OpnDataSet("select * from byrmst")

GrdHelp.DataSource =
Nothing

GrdHelp.DataSource = ds.Tables(0)

End Sub

Function OpnDataSet(ByRef strSQL As String) As DataSet

Dim ds As New DataSet

Try

Da = New SqlClient.SqlDataAdapter(strSQL, strConnection)

Da.Fill(ds, "Records")

OpnDataSet = ds

ds.Dispose()

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Function

 
grid

PrivateSub frmDataGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load


'SqlDataAdapter1.Fill(Grdtst1)

ds = OpnDataSet("select * from byrmst")

GrdHelp.DataSource =
Nothing

GrdHelp.DataSource = ds.Tables(0)

EndSub

Function OpnDataSet(ByRef strSQL AsString) As DataSet

Dim ds AsNew DataSet

Try

Da = New SqlClient.SqlDataAdapter(strSQL, strConnection)

Da.Fill(ds, "Records")

OpnDataSet = ds

ds.Dispose()

Catch ex As Exception

MsgBox(ex.Message)

EndTry

EndFunction


 
Thanx a lot ritesh it s working I m very very thankful to u .......

Ritesh I ' ve one more query abt latebinding like e.g

I m using a common toolbar & menu like MS Word Application , now i want if i press save button from MDIParent then it should call my active child form 's save function like activeform.fnsave but it s not running , it s not suporting late binding ,In VB6 it used to run but in vb.net it s not running xcan u give me the solution


thanx for giving me the solution
 
Hi

U can use
dgData.CurrentCell.ColumnNumber to get the curent column no. having focus..........

using this no. u can retreive the column name form underlying datasource........
 
Back
Top