1

hi friends...
i want to search a record from a datagridview with an input box...
Can anyone help me plz...
It's 4 my project ...
Need help plzzzz...

9
Contributors
27
Replies
104
Views
10 Years
Discussion Span
Last Post by Reverend Jim
Featured Replies
  • 1
    __avd 1,826   7 Years Ago

    Welcome anandkumarrs6. We appreciate your help. Have you ever noticed that the current thread is three years old? Please do not resurrect old threads and have a look at forum [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]rules[/URL]. Please read before posting - [url]http://www.daniweb.com/forums/thread78223.html[/url] Thread Closed. Read More

0

hi friends...
i want to search a record from a datagridview with an input box...
Can anyone help me plz...
It's 4 my project ...
Need help plzzzz...

Ok, what's the problem? Assume you want your users to enter a term in a textbox then you will search for that term. Is that correct? Give a little more info on the issue and what you need.

0

You could loop through the rows in the datagridview ? Or maybe re-query the datasource?

Dim intcount As Integer = 0
For Each Row As DataGridViewRow In DataGridView1.Rows
If DataGridView1.Rows(intcount).Cells(0).Value = "StringSearch" Then
'Do Something
intcount +=1
End If
Next Row

0

You Can use something like this using DataView

Dim dv As New DataView(ds.Tables(0))
dv.RowFilter = "FirstName = '" & TextBox1.Text & "'"
DataGrid1.DataSource = dv

You can replace the Textbox2.text to the value returned from the inputbox.

0

hi thanks it works...
the search works, it select only the fullrows containing the firstname i type in the input box but all the other data disappear.
i don't want it to disapppear, i want it to be in the datagrid..
help me plz

0

i want to search a particular rows in the datagrid..
for example Any columns containing the data the user want to type, i want only the the data to be selected


for ex the user may want to serach all female, then only the rows female will b selected

0
Private Function Find(ByVal StrSearchString As String) As Boolean

        DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect

        Dim intcount As Integer = 0
        For Each Row As DataGridViewRow In DataGridView1.Rows
            If DataGridView1.Rows(intcount).Cells(0).Value.ToString = StrSearchString Then
                DataGridView1.Rows(intcount).Selected = True                
                    Find = True
                Exit Function
            End If
            intcount += 1
        Next Row
        Find = False
    End Function
0

Hey Friends but where should i put the private function find
coz am using a button with an input box..
And wat should i put in the button search ,coz, there is nothing there except the input box...

0

Copy paste code... open form designer drop a button and a textbox on it, double click button then enter...

Call Find(textbox1.text)

Done.

0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call Find(TextBox1.Text)
    End Sub
0

hey i have already copy n paste the function on the form and put the code call find to the button but it doesn't works. i have enter something in the textbox 2 n then press the button but nothing happens.
Help Me plzzz

0

Hi triss can u help me how can i search name that starts with the letter F in a datagridview.
For example if i type F in the inputbox i got every name started with the letter F.

0

Hey guys I have been closely watching your threads regarding searching a record in a datagrid as I have the same problem as Geetajilo.

I can easily search for something in a datagrid by entering a field into a textbox and pressing the search button. This works fine when the record is already in the datagrid, but however how can you retrieve a record from the database and place it in the datagrid.??


Thanks for your time

0

You can do it by quering it based on a column name. So you have to write a backend query to bind your search to the GRID.

0
For Each CurrentRow As DataGridViewRow In DgCustomerList.Rows
            If CurrentRow.Cells(3).Value.ToString.Contains(TxtSearch.Text) Then
                CurrentRow.Selected = True
            Else
                DgCustomerList.Rows(0).Selected = True
            End If
        Next
    End Sub

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

0

PLZ HELP ME.. I WANT TO SEARCH A EMPLOYEE'S RECORD TO MY DATABASE ADODC IN SEARCH BOTTON(TEXT1) AND ONLY THE RECORDS OF EMPLOYEE VIEW IN THE DataGrid.. WHAT IS THE CODE FOR IT.? PLZZZZZZZZ.....

0

plz help me to sold my problem... I have a database(access) and all I want is to view all the records of the person that l've searching.. using textbox and view it in the DataGrid. I using vb6 and my database is access. what is the best code for my problem? plz........
:(

0

Please start a new thread for your question. Please ensure you post in the correct forum. Yours is a VB6 question. This is VB.net.

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.