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.
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.
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 StringFor i As Integer = 0 To(grdInvoice.Rows.Count) - 2CheckValue = grdInvoice.Rows(i).Cells(0).Value.ToString
If CheckValue = Item ThengrdInvoice.Rows(i).Cells(0).Selected = TrueMsgBox("Item Already Exists")
Please see the lines in 'Bold, Underline and Italic'
grdInvoice.ActiveRow = grdInvoice.Rows(j)
Exit ForEnd IfNext
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.
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.
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
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?
aftercellupdate didnt work, had to use the BeginInvoke to call the Method.
Thanks
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.
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.