Fix 'Find()' and 'FindNext()' methods in DataSource and DataView, and add them to DataBrowser.

[GB.DB.FORM]
* NEW: DataView: 'Find()' searches the entire view, whereas the new 'FindNext()' searches from the current index.
* NEW: DataBrowser: Add 'Find()' and 'FindNext()' method from DataView.
* BUG: DataSource: 'Find()' and 'FindNext()' methods now correctly detect the current connection.
This commit is contained in:
Benoît Minisini 2023-07-12 21:10:53 +02:00
parent d431251e2c
commit 13e65fa01d
5 changed files with 63 additions and 7 deletions

View File

@ -214,3 +214,16 @@ Public Sub Find(Where As String, ...)
$hForm.DataView.Find(Where, ...)
End
Public Sub FindNext(Where As String, ...)
$hForm.DataView.FindNext(Where, ...)
End
Public Sub MoveTo(Index As Integer)
$hForm.DataView.MoveTo(Index)
End

View File

@ -573,13 +573,13 @@ End
Public Function Find(Where As String, ...) As Integer
Return $hTable.Find($DB.Subst(Where, ...))
Return $hTable.Find(_GetDB().Subst(Where, ...))
End
Public Function FindNext(Index As Integer, Where As String, ...) As Integer
Return $hTable.Find($DB.Subst(Where, ...), Index)
Return $hTable.Find(_GetDB().Subst(Where, ...), Index)
End

View File

@ -1308,6 +1308,15 @@ Public Sub Find(Where As String, ...)
Dim iIndex As Integer
iIndex = GetSource().Find(Where, ...)
MoveTo(iIndex)
End
Public Sub FindNext(Where As String, ...)
Dim iIndex As Integer
iIndex = GetSource().FindNext(Index_Read() + 1, Where, ...)
MoveTo(iIndex)

View File

@ -71,7 +71,7 @@ Public Sub DataSource1_BeforeDelete(Keys As Variant[])
Next
Print
Stop Event
'Stop Event
End
@ -81,3 +81,22 @@ Public Sub DataSource1_Invalid(Field As String)
Stop Event
End
Public Sub Button2_Click()
DataBrowser1.MoveTo(2)
End
Public Sub btnFind_Click()
Dim iId As Integer
Try iId = CInt(txtId.Text)
If iId = 0 Then Return
iId = DataSource1.Find("id = &1", iId)
'DataSource1.MoveTo(iId)
DataBrowser1.MoveTo(iId)
End

View File

@ -6,10 +6,25 @@
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ Button1 Button
MoveScaled(1,0,16,4)
Visible = False
Text = ("Refresh")
{ Panel2 HBox
MoveScaled(1,0,72,4)
Spacing = True
{ Button1 Button
MoveScaled(0,0,16,4)
Visible = False
Text = ("Refresh")
}
{ Button2 Button
MoveScaled(17,0,16,4)
Text = ("Move")
}
{ txtId TextBox
MoveScaled(34,0,15,4)
}
{ btnFind Button
MoveScaled(51,0,16,4)
Text = ("Find")
}
}
{ DataSource2 DataSource
MoveScaled(3,5,69,87)