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
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
Not getting help from ur suggested code , please give me some other solution to put on datagrid .

thanx
 

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
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
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
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:

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
Hi,
what's the Datasource of ur Datagrid.?...................i assume it is

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


Regards,
Ritesh
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
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

 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
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


 

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
Hi,
Just replace............

GrdHelp.DataSource = ds.Tables(0)

with

GrdHelp.DataSource = ds.Tables(0).defaultview


Regards,
Ritesh
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
hye ritesh i m rthanxful u replied my query ,i m using dataset and via dataset i m binding my datagrid
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
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
 

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
Hi,
I am not sure but i think...........

ActiveMdiChild.Invoke can help u out............

Regards,
Ritesh
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
How Can I trap the Current Columns caption & Current colindex in dataGrid
 
Last edited:

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
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........
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
How can i false the visibility of a column in datagrid

1)I want to false the visibility of a columns can u suggest me how can i ?
2) Can I Fill the data in data grid via code means by defining columns ,rows at run time
 
Joined
Feb 21, 2005
Messages
21
Programming Experience
3-5
thnx but one more qry

How can i false the visibility of a column in datagrid

1)I want to false the visibility of a columns can u suggest me how can i ?
2) Can I Fill the data in data grid via code means by defining columns ,rows at run time
 
Top Bottom