i have 2 cursors. lets call them orders1 and 2
initially they are identical
i have a form with a grid on it and a couple buttons
the grids rowsource is set to the order2
when button 1 is clicked, i zap orders2 and insert into it from orders1
where orderamount > 1000
grid is refreshed and the data is there
when button 2 is clicked, i zap orders2 and insert into it from orders1
where orderamount > 10000
grid is refreshed and the data is there
i can do this all day and it works fine!
BUT... if i click on a row in the grid, and move my mouse wheel up and down,
i sometime loose the grid display right away or if i click back on button 1
no data is displayed...
data is in the table
i can see the right hand side scroll bar change sizes when i click on
different button and the data is updated, and sometimes, if i minimize my
form and restore it, and then click on another button, the data shows up
again...
HELP!!!! what going on here???
http://lmgtfy.com/?q=grid+deconstruction+vfp
Dan
"Brad" <Br...@discussions.microsoft.com> wrote in message
news:2059D036-843A-49ED...@microsoft.com...
First CJ, that worked!
and Dan, thats what i thought too so i created a standard table and tied the
grid to that table, i then moved records in and out of that table and i had
the same problem, and the table was always available...
this was a prototype form so it is all standard base class objects, straight
code, nothing fancy
if the form loads and i dont select anything on the grid to set focus to it,
it works fine. i can click back and forth on buttons all day and it works. as
soon as i click on a row in the grid, or tab to it so that it has focus and
then click on an option to update the data, it fails.
i added a text box and hid it behing the shape that the grid is over and
when changing the data in the table i first set focus to the textbox, changed
the data in the table, and set focus back to the grid and it worked...
as stated before, even though the grid displayed empty rows, the scroll bar
button size updated properly to indicate the proportion of data to the grid
size so it seems like it knew what the underlying data was... and this
behavior only happens when the grid has focus and i update the content of the
underlying table.
if the grid has focus and i press tab and then select a different option it
works fine.
i guess my for is a little special in that i am using a shape and a label as
a button so when clicking on it focus stays on the grid. if i use a regular
button, focus goes to the button and it works ok.
im stumped but removing focus from the grid before updating the underlying
table works consistently...
Dan, here is some sample code i whipped up from the problems i had.
click on a few of the shape buttons on top and you will see the problem
then click on the button on the bottom and you wont see the problem
happy foxing...
LOCAL oForm as Form
LOCAL ii as Integer
oForm = CREATEOBJECT('myForm')
oForm.Visible = .t.
oForm.AddObject('myButton1','myShape')
oForm.MyButton1.Top = 10
oForm.MyButton1.Left = 10
oForm.MyButton1.ButtonNo = 1
oForm.MyButton1.Visible = .t.
oForm.AddObject('myLabel1','myLabel')
oForm.myLabel1.Top = oForm.MyButton1.Top + 3
oForm.myLabel1.Left = oForm.MyButton1.Left + 3
oForm.myLabel1.Caption = 'Show CUST1'
oForm.myLabel1.ButtonNo = 1
oForm.myLabel1.Visible = .t.
oForm.AddObject('myButton2','myShape')
oForm.MyButton2.Top = 10
oForm.MyButton2.Left = oForm.MyButton1.Left + oForm.MyButton1.Width + 5
oForm.MyButton2.ButtonNo = 2
oForm.MyButton2.Visible = .t.
oForm.AddObject('myLabel2','myLabel')
oForm.myLabel2.Top = oForm.MyButton2.Top + 3
oForm.myLabel2.Left = oForm.MyButton2.Left + 3
oForm.myLabel2.Caption = 'Show CUST2'
oForm.myLabel2.ButtonNo = 2
oForm.myLabel2.Visible = .t.
oForm.AddObject('myButton3','myShape')
oForm.myButton3.Top = 10
oForm.myButton3.Left = oForm.MyButton2.Left + oForm.MyButton2.Width + 5
oForm.myButton3.ButtonNo = 3
oForm.myButton3.Visible = .t.
oForm.AddObject('myLabel3','myLabel')
oForm.myLabel3.Top = oForm.MyButton3.Top + 3
oForm.myLabel3.Left = oForm.MyButton3.Left + 3
oForm.myLabel3.Caption = 'Show CUST3'
oForm.myLabel3.ButtonNo = 3
oForm.myLabel3.Visible = .t.
SELECT Table2
oForm.AddObject('myGrid','Grid')
oForm.myGrid.Top = 40
oForm.myGrid.Height = oForm.Height - 80
oForm.myGrid.Left = 10
oForm.myGrid.Width = oForm.Width - 20
oForm.myGrid.RecordSource = 'Table2'
oForm.myGrid.Visible = .t.
oForm.AddObject('myButton4','myButton')
oForm.MyButton4.Top = oForm.myGrid.Top + oForm.myGrid.Height + 10
oForm.MyButton4.Left = 10
oForm.MyButton4.ButtonNo = 1
oForm.MyButton4.Caption = 'Show CUST1'
oForm.MyButton4.Visible = .t.
oForm.AddObject('myButton5','myButton')
oForm.MyButton5.Top = oForm.myButton4.Top
oForm.MyButton5.Left = oForm.MyButton4.Left + oForm.MyButton4.Width + 5
oForm.MyButton5.ButtonNo = 2
oForm.MyButton5.Caption = 'Show CUST2'
oForm.MyButton5.Visible = .t.
oForm.AddObject('myButton6','myButton')
oForm.MyButton6.Top = oForm.myButton4.Top
oForm.MyButton6.Left = oForm.MyButton5.Left + oForm.MyButton5.Width + 5
oForm.MyButton6.ButtonNo = 3
oForm.MyButton6.Caption = 'Show CUST3'
oForm.MyButton6.Visible = .t.
READ events
DEFINE CLASS myForm as Form
Height = 600
Width = 800
PROCEDURE Init
LOCAL ii as Integer
SET DELETED on
CREATE CURSOR Table1 (SomeID c(7), SomeQty I, SomeAmount Y)
FOR ii = 100 TO 399
INSERT INTO Table1 (SomeID, SomeQty, SomeAmount) ;
VALUES ('CUST'+TRANSFORM(ii),ii,ii*.25)
ENDFOR
SELECT 0
CREATE CURSOR Table2 (SomeID c(10), SomeQty I, SomeAmount Y)
INSERT INTO Table2 SELECT * FROM Table1 WHERE SomeID = 'CUST1'
GO TOP
ENDPROC
PROCEDURE UpdateData
LPARAMETERS myButtonNo
ENDPROC
PROCEDURE HighlightTab
LPARAMETERS myButtonNo, ShowIt
this.myButton1.BackColor = IIF(myButtonNo = 1 and
ShowIt=1,RGB(253,223,121),RGB(254,244,211))
this.myButton2.BackColor = IIF(myButtonNo = 2 and
ShowIt=1,RGB(253,223,121),RGB(254,244,211))
this.myButton3.BackColor = IIF(myButtonNo = 3 and
ShowIt=1,RGB(253,223,121),RGB(254,244,211))
ENDPROC
PROCEDURE UpdateData
LPARAMETERS myButtonNo
DO CASE
CASE myButtonNo = 1
SELECT Table2
ZAP
INSERT INTO Table2 SELECT * FROM Table1 WHERE SomeID = 'CUST1'
GO TOP
CASE myButtonNo = 2
SELECT Table2
ZAP
INSERT INTO Table2 SELECT * FROM Table1 WHERE SomeID = 'CUST2'
GO TOP
CASE myButtonNo = 3
SELECT Table2
ZAP
INSERT INTO Table2 SELECT * FROM Table1 WHERE SomeID = 'CUST3'
GO TOP
ENDCASE
this.myGrid.SetFocus
ENDPROC
PROCEDURE Unload
CLEAR EVENTS
ENDPROC
ENDDEFINE
DEFINE CLASS myShape as Shape
Width = 120
Height = 25
ButtonNo = 0
BackColor = RGB(254,244,211)
PROCEDURE Click
thisform.UpdateData(this.ButtonNo)
ENDPROC
PROCEDURE MouseEnter
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.HighlightTab(this.ButtonNo,1)
ENDPROC
PROCEDURE MouseLeave
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.HighlightTab(this.ButtonNo,0)
ENDPROC
PROCEDURE Click
thisform.UpdateData(this.ButtonNo)
ENDPROC
ENDDEFINE
DEFINE CLASS myLabel as Label
AutoSize = .t.
BackStyle = 0
ButtonNo = 0
PROCEDURE Click
thisform.UpdateData(this.ButtonNo)
ENDPROC
PROCEDURE MouseEnter
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.HighlightTab(this.ButtonNo,1)
ENDPROC
PROCEDURE MouseLeave
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.HighlightTab(this.ButtonNo,0)
ENDPROC
PROCEDURE Click
thisform.UpdateData(this.ButtonNo)
ENDPROC
ENDDEFINE
DEFINE class myButton as CommandButton
Width = 120
Height = 25
ButtonNo = 0
PROCEDURE Click
thisform.UpdateData(this.ButtonNo)
ENDPROC
ENDDEFINE