Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid does not refresh after adding empty row
Message
De
03/03/2003 11:29:09
 
 
À
03/03/2003 05:21:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00743140
Message ID:
00760390
Vues:
16
>>Now I created a simple repro in message #760102 for you which
>>I hope is easier to follow.
>>
>>How to refresh grid without losing all control sources and column settings ?
>
>As I replied to that message problem is in 'DeleteRow' method. Use go recno() to force a refresh (grid.refresh doesn't do the job).

Cetin,

thank you for reply.
I added
GO (RECNO()) IN mitteakt
line to deleterow method but grid does not refresh.

Any idea ?

Code to reproduce:
SET TALK off
set excl off
set compatible foxplus
SET SAFETY OFF
set exact on
set deleted on
set udfparms to REFERENCE

SET SYSMENU TO
SET SYSMENU AUTOMATIC
DEFINE PAD Action OF _MSYSMENU PROMPT "Action"
ON PAD Action OF _MSYSMENU ACTIVATE POPUP Action
DEFINE POPUP Action MARGIN RELATIVE
DEFINE BAR 1 OF Action PROMPT "Add" KEY CTRL+N, "" 
DEFINE BAR 2 OF Action PROMPT "Delete" KEY CTRL+T, "" 
ON SELECTION BAR 1 OF Action _screen.activeform.addrow()
ON SELECTION BAR 2 OF Action _screen.activeform.deleterow

CREATE TABLE mitteakt ( klient c(12), toode c(20) )
APPEND BLANK
APPEND BLANK
use

obrowse1=NEWOBJECT("browse1")
obrowse1.Show

keyboard '{ctrl+end}{ctrl+T}'
keyboard '{ctrl+T}'
keyboard '{ctrl+n}'
on shutdown onshut()
READ EVENTS
return

PROCEDURE onshut
SET SYSMENU TO defa
quit
ENDPROC

**************************************************
DEFINE CLASS browse1 AS form

ADD OBJECT gridbase1 AS grid WITH ;
		Name = "GridBase1"

	PROCEDURE SaveChanges
		TableUpdate(2, .T., 'mitteakt' )
	ENDPROC


	PROCEDURE addrow
      thisform.SaveChanges()
		sele mitteakt
		append blank
		REPLACE klient WITH 'hello'
	ENDPROC

	PROCEDURE deleterow
		if deleted(thisform.gridbase1.recordsource)
		  thisform.gridbase1.refresh()
		  return
		  endif

		sele (thisform.gridbase1.recordsource)

		do case
		  case recno(thisform.gridbase1.recordsource)>0
		    if cursorgetprop( 'Buffering', thisform.gridbase1.recordsource ) != 1
		      tablerevert(.f., thisform.gridbase1.recordsource )
		      endif    
		    sele (thisform.gridbase1.recordsource)

		    delete
		    skip
 if cursorgetprop( 'Buffering', thisform.gridbase1.recordsource ) != 1
		      tableupdate(2, .t., thisform.gridbase1.recordsource )
		      endif    

		    if eof() and !bof()
		      skip -1
		      endif

		  case recno(thisform.gridbase1.recordsource)<0
	     
		     skip
		    if eof()
		      skip -1
		      if !bof()
		       skip -1
		       endif
		     endif
		    tablerevert(.t.)
		  endcase
		thisform.gridbase1.refresh()

* Following code is added according to Cetin suggestion:
SELECT mitteakt
IF RECNO()<0 OR RECNO()<=RECCOUNT()
        GO (RECNO()) IN mitteakt
ENDIF

	ENDPROC

	PROCEDURE saverow
      this.SaveChanges()
	ENDPROC


	PROCEDURE QueryUnload
      this.SaveChanges()
	ENDPROC


	PROCEDURE Load
		set taLk off
		set multilock Off
SET TALK off
set excl off
set compatible foxplus
set exact on
set near on
set deleted on
set udfparms to reference

		USE mitteakt IN 0 
	ENDPROC

	PROCEDURE gridbase1.Init
		set multilock on
		this.recordsource= 'mitteakt'
		cursorsetprop( 'Buffering', 5, this.recordsource )
	ENDPROC

    * Mr. Cetin code to dedect row change. Thanks!
	PROCEDURE gridbase1.BeforeRowColChange
		LPARAMETERS nColIndex

		local llChangingRow
		llChangingRow = .f.
		with this
		 if mdown()
		    local lnBottom, lnTop, lnMouseRowPos
			lnBottom	= .top+.headerheight+ .relativerow * .rowheight
			lnTop		= m.lnBottom - this.rowheight
			lnMouseRowPos	= mrow(wontop(),3)
			llChangingRow	= !between( m.lnMouseRowPos, m.lnTop, m.lnBottom)
		   if !betw( m.lnMouseRowPos, .top, .top+.height )
		      llChangingRow	= .f.
		      endif
		  else
		local llastke
		llastke = lastkey()

		llChangingRow	= inlist(lastkey(),24,5,18,3,23, 29)
		 endif
		endwith

		if m.llChangingRow 
           thisform.SaveChanges()

		  if !betw( recno(this.recordsource), 1, recc(this.recordsource) )
		    nodefault
		    go bottom in this.recordsource
		    this.setfocus()
		    endif
		  endif
	ENDPROC
ENDDEFINE
Andrus
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform