Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Find row and set the row as selected

Find row and set the row as selected

New Discussion
april
april asked on Oct 28, 2009 8:27 PM

Hello Team,

We are using Infragistics 8.3 and MS VS 2008. In the infragistics win grid we want to find the particular value of a particular column and set the entrie row to selected.

Is there any way to find the value in the grid and set the row as selected. The value which we are searching is an unique one and we would be searching it in a single column.

Thanks in advance.

 

 

Sign In to post a reply

Replies

  • 0
    Mike Saltzman
    Mike Saltzman answered on Jan 5, 2009 4:04 PM

    Hi,

    There's no built-in search functionality in the grid. You would have to loop through the grid rows and examine the row.Cells[column name].Value to find the rowyou want. Once you find the row, you can just set the Selected propery on the row to true. Or maybe set the grid's ActiveRow to the row you want.

    • 0
      khalid
      khalid answered on Sep 17, 2009 2:58 AM

      I am trying to find the row, its works, but i am unable to select the row or make it active, it moves to the next cell

      here is the sample code

      Dim CheckValue As String
      For i As Integer = 0 To
      (grdInvoice.Rows.Count) – 2
      CheckValue = grdInvoice.Rows(i).Cells(0).Value.ToString

      If CheckValue = Item Then
      grdInvoice.Rows(i).Cells(0).Selected = True
      MsgBox("Item Already Exists") 

       

       

      grdInvoice.ActiveCell = grdInvoice.Rows(i).Cells(0)
      grdInvoice.PerformAction(EnterEditMode,
      False, False)
      grdInvoice.Focus()

       

      End If
      Next

       

      • 0
        april
        april answered on Sep 18, 2009 7:03 AM

        Please see the lines in 'Bold, Underline and Italic'

        Dim CheckValue As String
        For i As Integer = 0
        To
        (grdInvoice.Rows.Count) – 2
        CheckValue = grdInvoice.Rows(i).Cells(0).Value.ToString

        If CheckValue = Item Then
        grdInvoice.Rows(i).Cells(0).Selected =
        True
        MsgBox("Item Already Exists"
        ) 

        grdInvoice.ActiveRow = grdInvoice.Rows(j)

         

        grdInvoice.ActiveCell = grdInvoice.Rows(i).Cells(0)

         

        Exit For
        End If
        Next

      • 0
        khalid
        khalid answered on Sep 18, 2009 4:22 PM

        i have moved the msgbox right before the exit for.

        I can see the activerow selected but after i press ok on the msgbox, it goes back to the next cell of the last row.

      • 0
        april
        april answered on Sep 22, 2009 7:10 AM

        Have you tried the code given by me ? after the message box try setting the active row and active cell and then write exit for ? let me know how it goes.

      • 0
        khalid
        khalid answered on Oct 26, 2009 5:57 PM

        tried it , didnt work.

        after i hit ok on the message box, the keyboard cursor goes on the next column of the last row.

        here's my code

            Private Function CheckItemInGrid(ByVal Item As String) As Boolean
                Dim CheckValue As String

                For i As Integer = 0 To (grdInvoice.Rows.Count) – 2
                    CheckValue = grdInvoice.Rows(i).Cells(0).Value.ToString

                    If CheckValue = Item Then
                        grdInvoice.Rows(i).Cells(0).Selected = True
                        MsgBox("Item Already Exists")

                        'grdInvoice.ActiveRow.Delete(False)
                        grdInvoice.ActiveRow = grdInvoice.Rows(i)
                        grdInvoice.ActiveCell = grdInvoice.ActiveRow.Cells(0)
                        'grdInvoice.PerformAction(EnterEditMode, False, False)

                        Return True

                        Exit For
                        Exit Function
                    End If
                Next

                Return False
            End Function

         

      • 0
        Mike Saltzman
        Mike Saltzman answered on Oct 27, 2009 5:05 PM

        This sounds like a timing problem, but it's not clear to me what you are actually doing here. From what event is this code being called? What is the user doing to trigger it?

      • 0
        khalid
        khalid answered on Oct 27, 2009 5:14 PM

        the function is being called from AfterExitMode of the grid, the function is used to check if any duplicat item is found in the column, if its found then it should select that cell and EnterEditMode.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Oct 28, 2009 2:57 PM

        Showing a MessageBox during AfterEnterEditMode could certainly cause a problem. I'd recommend trying this in AfterCellUpdate, instead.

        If that doesn't help, then you probably need to institute some sort of delay before displaying the MessageBox. Try taking the code out of the event handler and put it into a separate method. Then, in the event handler, use a BeginInvoke to call the method. That should create enough of a delay for the grid to finish whatever processing it is doing before it tries to enter edit mode on the new cell.

      • 0
        khalid
        khalid answered on Oct 28, 2009 8:27 PM

        aftercellupdate didnt work, had to use the BeginInvoke to call the Method.

        Thanks

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
april
Favorites
0
Replies
10
Created On
Oct 28, 2009
Last Post
17 years ago

Suggested Discussions

Tags

Created by

Created on

Oct 28, 2009 8:27 PM

Last activity on

Feb 20, 2026 12:32 PM