in some of my browse the user can switch the column sets from 1, 2, ... n, to show different, predefined columns of the same table by clicking the K_CTRL_RIGHT/_LEFT keys. The program then calls a function 'RedesignBrowse()', which deletes all existing columns before it builts the new view with 'oBrw:AddCol()'.
This works well for the last months without any crashes or other problems.
Now, if I define one or more columns for inline editing, the functions crashes without any error when switching the column set.
Here is a sample to show the problem:
What is wrong?
This works well for the last months without any crashes or other problems.
Now, if I define one or more columns for inline editing, the functions crashes without any error when switching the column set.
Here is a sample to show the problem:
#include "FiveWin.ch"
#include "XBrowse.ch"
STATIC oWnd, oBrw, oCol
FUNCTION Main()
USE Customer
DEFINE WINDOW oWnd MENU BuildMenu()
@ 0, 0 XBROWSE oBrw OF oWnd ALIAS "Customer"
oBrw:lFastEdit := .T.
oCol := oBrw:AddCol()
oCol:bStrData := { || Customer->First }
oCol:cHeader := "First"
oCol:nEditType := EDIT_GET
oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, ( DbAppend(), oBrw:Refresh() ),), If( nKey == VK_RETURN, Customer->First := xVal,) }
oCol := oBrw:AddCol()
oCol:bStrData := { || Customer->Last }
oCol:cHeader := "Last"
oCol:nEditType := EDIT_GET
oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, DbAppend(),), If( nKey == VK_RETURN, ( Customer->Last := xVal, DbAppend(), oBrw:Refresh() ),) }
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd
RETURN NIL
FUNCTION BuildMenu()
LOCAL oMenu
MENU oMenu
MenuItem "Redesign browse" ACTION RedesignBrowse()
ENDMENU
RETURN oMenu
FUNCTION RedesignBrowse()
DO WHILE .T.
IF Len( oBrw:aCols ) == 0
EXIT
ELSE
oBrw:DelCol( 1 )
ENDIF
ENDDO
oCol := oBrw:AddCol()
oCol:bStrData := { || Customer->First }
oCol:cHeader := "First"
oCol:nEditType := EDIT_GET
oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, ( DbAppend(), oBrw:Refresh() ),), If( nKey == VK_RETURN, Customer->First := xVal,) }
oCol := oBrw:AddCol()
oCol:bStrData := { || Customer->Last }
oCol:cHeader := "Last"
oCol:nEditType := EDIT_GET
oCol:bOnPostEdit := { | oCol, xVal, nKey | If( RecCount() == 0, DbAppend(),), If( nKey == VK_RETURN, ( Customer->Last := xVal, DbAppend(), oBrw:Refresh() ),) }
oCol := oBrw:AddCol()
oCol:bStrData := { || Customer->Street }
oCol:cHeader := "Street"
oCol := oBrw:AddCol()
oCol:bStrData := { || "test" }
oCol:cHeader := "test"
oBrw:Refresh( .T. )
RETURN NILWhat is wrong?
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86