CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2003
    Location
    bangalore
    Posts
    31

    searching for text in datagrid in windows forms

    hi,

    I have to search the text in datagrid in windows forms application. I have to find the matching text and then make to select that cell which contains that text. It is just like Finding text.
    I have not found proper functions to implement it. Not only that, if that cell is not in visible region, i have to scroll the datagrid to show that activated cell. All this functionality i needed in windows Forms Application, not in web forms. can any one can help me.

    bye

  2. #2
    Join Date
    Apr 2003
    Location
    bangalore
    Posts
    31

    finding text in datagrid in windows forms

    hi,

    i found how to search text in datagrid, by using binding context, we can able to get number of rows and number of columns, then we can able to search each cell. But one thing left is, how to make a particular cell be selected??

    Not only that, i need how to scroll datagrid, can any one will help me

    bye

  3. #3
    Join Date
    Aug 2000
    Posts
    242
    I think this should work (if I got your question right)



    PHP:--------------------------------------------------------------------------------
    private void serchGrid(object Obj ,DataGridCommandEventArgs e )
    {
    for (i=0;i<lastrow;i++)
    {
    //The following line is not so good since it opens the cell for change
    //still it let you get to the right row (I dont think it will
    //be hard to find the right property of datagrid that just directs
    //to the wanted row/
    DataGrid1.EditItemIndex=i;
    for (i=j;i<lastcol;j++)
    {

    String strID=((TextBox) e.Item.Cells[j].Controls[0]).Text ;
    }
    }
    }

    --------------------------------------------------------------------------------


    the strID is the value of the current cell - manipulate it as you like...

  4. #4
    Join Date
    Apr 2003
    Location
    bangalore
    Posts
    31

    I needed using Windows Forms

    hi,

    I saw your code. But i need to implement it by using Windows Forms. But not by using the classes of WebControls. So, i con't able to use it. Can you help me by providing the way to solve the problem by using System.Windows.Forms but not System.Web.

    I have another problem of selecting cell. For this, there is select function in datagrid. But it is not working, when i try to select from another form. But i need to manipulate from another form. Can you provide me any solution?

    bye

    .........................................................................................................

    Originally posted by giladasaf
    I think this should work (if I got your question right)



    PHP:--------------------------------------------------------------------------------
    private void serchGrid(object Obj ,DataGridCommandEventArgs e )
    {
    for (i=0;i<lastrow;i++)
    {
    //The following line is not so good since it opens the cell for change
    //still it let you get to the right row (I dont think it will
    //be hard to find the right property of datagrid that just directs
    //to the wanted row/
    DataGrid1.EditItemIndex=i;
    for (i=j;i<lastcol;j++)
    {

    String strID=((TextBox) e.Item.Cells[j].Controls[0]).Text ;
    }
    }
    }

    --------------------------------------------------------------------------------


    the strID is the value of the current cell - manipulate it as you like...

  5. #5
    Join Date
    Apr 2003
    Location
    bangalore
    Posts
    31

    some partial solution related to selection of cell

    hai,

    I dont think, selecting a cell will be possible from another form. One thing we have to do is, any way the selection code should be written in the form where datagrid is present, and call that method from the second form whenever selection is required.
    I think it will solve the problem to some extent.


    bye

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured