We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

FindRecordInGrid

I modified an example that I found to the following... The problem is that if I set the grid to start at position 0,) gridRangeInfo(0,Column) It doesn't find anything in the grid. However, if I set it to 1, it works, but only if there are 2 items in the grid. What we're trying to do is when someone adds something to the grid, we look to see if it already exists before allowing it to happen. Private Function FindRecordInGrid(ByVal Value As String, ByVal iColumn As Integer, ByVal dg As Syncfusion.Windows.Forms.Grid.GridDataBoundGrid) As Boolean Dim fr As GridFindReplaceDialogSink = New GridFindReplaceDialogSink(dg) Dim fre As GridFindReplaceEventArgs Dim frLocationInfo As Object = Nothing With dg .ForceCurrentCellMoveTo = True .CurrentCell.MoveTo(1, iColumn) End With frLocationInfo = GridRangeInfo.Cell(1, iColumn) fre = New GridFindReplaceEventArgs(Value, "", GridFindTextOptions.ColumnOnly, frLocationInfo) If Not fr.Find(fre) Is Nothing Then Return True Else Return False End If End Function

1 Reply

AD Administrator Syncfusion Team October 17, 2003 01:05 PM UTC

You can work around this problem by starting at the bottom and working up since the last row in the datagrid is the AddNew row. If you have turned off the AddNew row, you can still use it to work around the problem I think. Attached is a little sample.

Loader.
Live Chat Icon For mobile
Up arrow icon