dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: [RESOLVED] Search for a value in a datagrid view

  1. #1
    Join Date
    Oct 2009
    Posts
    27

    [RESOLVED] Search for a value in a datagrid view

    Hi All
    I have a datagridview. The database is unbounded. When I display the database in the datagridview. I want to search for a value in a datagrid view. For this I want to add a textbox. The user enters a value in a textbox. Then the search could be able to search for the value entered in the textbox in the datagrid view .Can any one help me? I am trying for it but not getting

    Thanks for any help.

  2. #2
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: Search for a value in a datagrid view

    Code:
    dim colcount as integer
    dim rowcount as integer
    colcount=DataGrid.ColumnCount
    rowcount =DataGrid.rowCount
    for i=0 to rowcount
    for j=0 to colcount
    if (txtbox.text =DataGrid.Item(rowcount, colcount).Value) then
    msgbox("value found",0)
    endif

  3. #3
    Join Date
    Oct 2009
    Posts
    27

    Re: Search for a value in a datagrid view

    Thanks alot for ur reply.

    But i want to restrore the datagridview with the latest results set.

    is it possibule?

    Thanks

  4. #4
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: Search for a value in a datagrid view

    You can do that.


    i can tell you the logic.
    Search the value as mentioned early. If value found, then again do a select statment for the table with the value given in the textbox as parameter and the result of this select statment to be filled in the datagrid.

  5. #5
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: Search for a value in a datagrid view

    You can do that.

    i can tell you the logic.
    Search the value as mentioned early. If value found, then again do a select statment for the table with the value given in the textbox as parameter and the result of this select statment to be filled in the datagrid
    Quote Originally Posted by LakshmiP View Post
    The database is unbounded
    .
    I am not sure how this is going to affect the flow/ logic
    Last edited by makdu; October 29th, 2009 at 02:29 AM.

  6. #6
    Join Date
    Oct 2009
    Posts
    27

    Re: Search for a value in a datagrid view

    Thanks alot for ur logic.

    its working fine.

  7. #7
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: Search for a value in a datagrid view

    Nice to hear that you got it worked.
    It will be good if you can post the code here so that others will also get idea about datagrid data modificaiton.
    Also mark the thread as resolved

  8. #8
    Join Date
    Oct 2009
    Posts
    27

    Re: [RESOLVED] Search for a value in a datagrid view

    Just i pass the text box value to select query again and fill the datagrid again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)