Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grids 101
Message
From
10/11/2003 10:18:00
 
 
To
10/11/2003 05:14:18
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00846808
Message ID:
00848292
Views:
39
I set the height in the refresh because the number of records in the cursor in my app keeps on changing.

BUT, that wasn't the reason I sent you the code; I sent it to you to show you that in the case of my code, there is still undesirable scrolling. Maybe it's because of the checkbox somehow. Can you help on that?

Yossi

>Yossi Yossi,
>It's just your bad calculation. Try to change :
>
> height=93
> PROCEDURE REFRESH
> DODEFAULT()
> THIS.HEIGHT = 38 + (18*(RECCOUNT('myCursor') - 1))+1
> ENDPROC
>
>Or better :
>
>this.Height =  Sysmetric(11)*2 + ;
>  this.HeaderHeight + this.RowHeight*Reccount()
>
However I don't see the point setting the height again and again in refresh. I'd do :
>
>DEFINE CLASS badgrid AS GRID
>	WIDTH=180
>	TOP=10
>	LEFT=10
>	SCROLLBARS=0
>	COLUMNCOUNT=2
>*	height=93
>
>	PROCEDURE Init
>*	DODEFAULT()
>*	THIS.HEIGHT = 38 + (18*(RECCOUNT('myCursor') - 1))+1
>	this.Height =  Sysmetric(11)*2 + ;
>               this.HeaderHeight + this.RowHeight*Reccount()
>	ENDPROC
>ENDDEFINE
>
>Cetin
>
>
>>Cetin:
>>
>>Consider this:
>>
>>
>>oForm = CREATEOBJECT('ItDoesntWork')
>>oForm.SHOW
>>READ EVENTS
>>
>>DEFINE CLASS ItDoesntWork AS FORM
>>	HEIGHT=120
>>	WIDTH=200
>>	ADD OBJECT myGrid AS badgrid
>>
>>	PROCEDURE LOAD
>>	CREATE CURSOR myCursor (myValue i, myCheckBox L)
>>	FOR ix=1 TO 4
>>		INSERT  INTO myCursor VALUES (ix, .F.)
>>	ENDFOR
>>	LOCATE
>>	ENDPROC
>>
>>	PROCEDURE INIT
>>	WITH THIS.myGrid.COLUMNS(2)
>>		.REMOVEOBJECT('Text1')
>>		.ADDOBJECT('Check1','myCheckBox')
>>		.Check1.VISIBLE = .T.
>>		.SPARSE=.F.
>>		.header1.caption='not suppressed'
>>	ENDWITH
>>	WITH THIS.myGrid.COLUMNS(1)
>>		.REMOVEOBJECT('Text1')
>>		.ADDOBJECT('Text1','myTxtBox')
>>		.Text1.VISIBLE = .T.
>>		.header1.caption='suppressed'
>>	ENDWITH
>>	ENDPROC
>>
>>	PROCEDURE QUERYUNLOAD
>>	CLEAR EVENTS
>>	ENDPROC
>>ENDDEFINE
>>
>>DEFINE CLASS myTxtBox AS TEXTBOX
>>	BORDERSTYLE=0
>>	PROCEDURE KEYPRESS
>>	LPARAMETERS nKeyCode,nShilftAltCtrl
>>	IF INLIST(nKeyCode,24,145,3) AND RECNO()=RECCOUNT()
>>		NODEFAULT
>>	ENDIF
>>	ENDPROC
>>ENDDEFINE
>>
>>DEFINE CLASS myCheckBox AS CHECKBOX
>>ENDDEFINE
>>
>>DEFINE CLASS badgrid AS GRID
>>	WIDTH=180
>>	TOP=10
>>	LEFT=10
>>	SCROLLBARS=0
>>	COLUMNCOUNT=2
>>	height=92
>>	PROCEDURE REFRESH
>>	DODEFAULT()
>>	THIS.HEIGHT = 38 + (18*(RECCOUNT('myCursor') - 1))
>>	ENDPROC
>>ENDDEFINE
>>
>>
>>BTW, the problem occurs whether or not I have the REFRESH in the grid or not.
>>
>>Yossi
>>>Well I still can't get it how you can do that with that code I originally provided. Are you sure your cursor has only 3 records but not 4 and you're using the code I wrote but not the one you modified ?
>>>I ran this code which contains what I said and works wonderfully well for me. Well maybe you meant pagedown but not down arrow which I failed to add ?In which version of VFP it's failing ?
>>>
>>>oForm = Createobject('ItWorks')
>>>oForm.Show
>>>Read Events
>>>
>>>Define Class ItWorks As Form
>>>  Height=95
>>>  Width=100
>>>  Add Object myGrid As Grid ;
>>>    with Height=75, Width=80, Top=10,Left=10,ScrollBars=0
>>>
>>>  Procedure Load
>>>  Create Cursor myCursor (myValue i)
>>>  For ix=1 To 3
>>>    Insert Into myCursor Values (ix)
>>>  Endfor
>>>  Locate
>>>Endproc
>>>
>>>  Procedure Init
>>>  With This.myGrid.Columns(1)
>>>    .RemoveObject('Text1')
>>>    .AddObject('Text1','myTxtBox')
>>>    .Text1.Visible = .T.
>>>  Endwith
>>>Endproc
>>>
>>>  Procedure QueryUnload
>>>  Clear Events
>>>Endproc
>>>Enddefine
>>>
>>>Define Class myTxtBox As TextBox
>>>  BorderStyle=0
>>>  Procedure KeyPress
>>>  Lparameters nKeyCode,nShilftAltCtrl
>>>  If Inlist(nKeyCode,24,145,3) And Recno()=Reccount()
>>>    Nodefault
>>>  Endif
>>>Endproc
>>>Enddefine
>>>
Cetin
>>>
>>>
>>>>Suppose there are three records in the cursor and I set the height of the grid to three rows, when the grid first displays, it shows the three records as I want.
>>>>
>>>>However, if focus is on the second row and I press the down arrow, instead of focus moving to the third row, the third record jumps to the second row, the secod row jumps to the first and the third row is now empty.
>>>>
>>>>I don't want that. I want focus to shift to the third row. BTW, I have the same problem if I select the third row by clicking the mouse cursor.
>>>>
>>>>>">but if I want the capability to use it except for the last line, then this doesn't work, since the undesirable behaviour occurs when going from the second to last row to the last! Even saying..."
>>>>>
>>>>>I don't understand what you mean. You're talking over a modified code and I don't understand what the undesirable behavior is. Works for me.
>>>>>
>>>>>Cetin
>>>>>
>>>>>>Cetin:
>>>>>>
>>>>>>Your solution is not 100% complete. If I wanted to completely disable the down arrow, I could say:
>>>>>>
>>>>>>
>>>>>>If InList(nKeyCode,24,145)
>>>>>>
>>>>>>
>>>>>>but if I want the capability to use it except for the last line, then this doesn't work, since the undesirable behaviour occurs when going from the second to last row to the last! Even saying
>>>>>>
>>>>>>
>>>>>>If InList(nKeyCode,24,145) and Recno()=Reccount() - 1
>>>>>>
>>>>>>
>>>>>>would not work, for that would prevent the user from moving from the second to last row to the last.
>>>>>>
>>>>>>Yossi
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>Einar:
>>>>>>>>
>>>>>>>>My record pointer is at the top of the table.
>>>>>>>>This is a case where I DO NOT want scrolling and I took advantage of the scrollbars = 0 option. Nevertheless, if and only if the grid has the same or less number of rows as there are records in the cursor, it allows me to scroll with the down arrow or with pagedown, leaving an empty row at the bottom. I do not want the user to be able to scroll. I will provide her with enough rows to view the data.
>>>>>>>>
>>>>>>>>Yossi
>>>>>>>>
>>>>>>>>>>If the grid has the same number of rows as there are records in the cursor, if I press the down arrow, the top rows will disappear one by one. The only way that I have have found to avoid this behavior is to make the grid at least one full row taller than there are records, NOT a very elegant solution! Any suggestions?
>>>>>>>>>
>>>>>>>>>I don't think I understand your problem. One reason for using a grid is because you want to display more information than you can fit on your screen i.e. so you can navigate with the scrollbars.
>>>>>>>>>Maybe your problem is that your record pointer is at EOF
>>>>>>>
>>>>>>>In column where you put filename :
>>>>>>>
>>>>>>>* Text1.keypress
>>>>>>>LPARAMETERS nKeyCode, nShiftAltCtrl
>>>>>>>If InList(nKeyCode,24,145) and Recno()=Reccount()
>>>>>>> nodefault
>>>>>>>endif
>>>>>>>
>>>>>>>Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform