The browse does not refresh the edited row and does not position the cursor correctly.
Below I have attached a sample. Try to edit the name column of a row to see it please.
- Code: Select all Expand view RUN
- #include "fivewin.ch"
static oCn
function Main()
local oRs, oDlg, oBrw, oFont
FWCONNECT oCn HOST "localhost" USER "root" PASSWORD "mypass" DATABASE "deneme" PORT 3306
oCn:lShowErrors := .T.
CreateTables()
oRs := oCn:RowSet( "SELECT ID, NAME FROM test_unq")
oRs:Sort := "NAME"
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12
DEFINE DIALOG oDlg SIZE 500,600 FONT oFont PIXEL TRUEPIXEL TITLE "Test Unique Key"
@ 70,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs AUTOCOLS AUTOSORT ;
COLSIZES -10, -30 ;
CELL LINES NOBORDER
oBrw:CreateFromCode()
@ 20, 20 BTNBMP PROMPT "ADD" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION oRs:EditBaseRecord( nil, .t., { |oRec| MyEditDlg( oRec ) }, oBrw )
@ 20,130 BTNBMP PROMPT "EDIT" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION oRs:EditBaseRecord( nil, .f., { |oRec| MyEditDlg( oRec ) }, oBrw )
@ 20,240 BTNBMP PROMPT "REFRESH" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION ( oRs:Requery(), oBrw:Refresh(), oBrw:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
return nil
function CreateTables()
oCn:DropTable( "test_unq" )
if !oCn:TableExists( "test_unq" )
oCn:CreateTable( "test_unq", { ;
{ "NAME", 'C', 30, 0, "UNI, NOT NULL" }, ;
{ "UNIT", 'C', 2, 0 }, ;
{ "PRICE", 'N', 6, 2 } } )
oCn:Insert( "test_unq", "NAME, UNIT, PRICE", ;
{ {'BANANA', 'KG', 5.25}, {'SARDINES', 'AD', 2.15}, {'APPLE', 'KG', 3.50}, {'STRAWBERRY', 'KG', 1.30}, ;
{'MELON', 'KG', 3.45}, {'ZERDECAL', 'GR', 8.65}, {'LEMON', 'KG', 1.00}, {'CRANBERRY', 'KG', 3.50} } )
endif
return nil
static function MyEditDlg( oRec )
local lNew := ( oRec:RecNo == 0 )
local oDlg, oFont
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12
DEFINE DIALOG oDlg SIZE 400,300 PIXEL TRUEPIXEL FONT oFont
@ 030,020 SAY "ID:" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 060,020 SAY "Name:" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 090,020 SAY "Unit" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 120,120 SAY "Price" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 030,120 GET oRec:ID SIZE 100,22 PIXEL OF oDlg WHEN .F.
@ 060,120 GET oRec:NAME SIZE 240,22 PIXEL OF oDlg
@ 090,120 GET oRec:UNIT SIZE 50,22 PIXEL OF oDlg
@ 120,120 GET oRec:PRICE SIZE 50,22 PIXEL OF oDlg PICTURE '999.99'
@ 170,020 BTNBMP PROMPT "Save" SIZE 150,30 PIXEL FLAT OF oDlg ;
ACTION ( If( oRec:Modified(), oRec:Save(), nil ), oDlg:End() )
@ 170,240 BTNBMP PROMPT "Cancel" SIZE 150,30 PIXEL FLAT OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED ON PAINT oDlg:Box( 15, 10, 155, 390 )
return nil