Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DownArrow in Centered Checkbox in Grid
Message
From
01/04/2002 17:09:29
 
 
To
01/04/2002 16:16:29
Jill Derickson
Software Specialties
Saipan, CNMI
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00577753
Message ID:
00639697
Views:
26
>>>>>>Hi All,
>>>>>>
>>>>>>From previous posts on the UT, I've created a container class so that I can have a checkbox centered in a grid colum. It all works well.
>>>>>>
>>>>>>I've noticed, though, when when a DownArrow is pressed when the checkbox has focus, the resulting action is like a Tab, i.e., focus moves to the the next column to the right in the grid, rather than moving down a row.
>>>>>>
>>>>>>I believe that this is due to the container, since when I put a regular checkbox in the column instead of the container, the DownArrow works as expected.
>>>>>>
>>>>>>Any input/help is appreciated.
>>>>>>
>>>>>>J
>>>>>>
>>>>>>P.S. The class is just a container with a checkbox, with the following code in the container init:
>>>>>>
>>>>>>
With this.ChkBox
>>>>>>  If Type("this.parent.ControlSource")#"U"
>>>>>>    .ControlSource = this.parent.ControlSource
>>>>>>  EndIf
>>>>>>  .Left = this.parent.Width/2 - .Width/2
>>>>>>  If this.Height > .Height
>>>>>>    .Top = this.parent.Height/2 - .Height/2
>>>>>>  EndIf
>>>>>>EndWith
>>>>>
>>>>>Jill,
>>>>>This works for me :
>>>>>
*CheckBox.Keypress
>>>>>Lparameters nKeyCode, nShiftAltCtrl
>>>>>With this.parent.parent.parent
>>>>>  lnRows = int((.Height - (sysmetric(8)+.HeaderHeight))/.RowHeight)
>>>>>  If nKeyCode = 24
>>>>>    Nodefault
>>>>>    If .RelativeRow = lnRows
>>>>>      .DoScroll(1)
>>>>>    Endif
>>>>>    .ActivateCell(.RelativeRow+1,.RelativeColumn)
>>>>>  Endif
>>>>>  If nKeyCode = 5
>>>>>    Nodefault
>>>>>    If .RelativeRow = 1
>>>>>      .DoScroll(0)
>>>>>    Endif
>>>>>    .ActivateCell(.RelativeRow-1,.RelativeColumn)
>>>>>  Endif
>>>>>Endwith
Cetin
>>>>
>>>>I was refered to this thread. I have a checkbox centered by wraping it with a container and I have the same key board action problem as mentioned here. I tried to add code in keypress as you suggested here. However, the keypress does not get fired at all. I added my centered checkbox through addobject method in column's init(). It works fine with mouse but not key board. Any idea what I did wrong? Thanks.
>>>
>>>Are you sure the checkbox visible (it's set to visible=.F. when added at run time)?
>>>
>>>This is the code I ended up using in KeyPress:
>>>
>>>LPARAMETERS nKeyCode, nShiftAltCtrl
>>>
>>>LOCAL cGridRecordSource
>>>
>>>cGridRecordSource = This.Parent.Parent.Parent.RecordSource
>>>
>>>If nKeyCode = 24	&& down arrow
>>> Nodefault
>>> IF !EOF(cGridRecordSource)
>>>  SKIP IN (cGridRecordSource)
>>> ENDIF
>>>ELSE
>>> IF nKeyCode = 5	&& up arrow
>>>  Nodefault
>>>  IF !BOF(cGridRecordSource)
>>>    SKIP -1 IN (cGridRecordSource)
>>>  ENDIF
>>> Endif
>>>Endif
>>>
>>>
>>>J
>>
>>Thanks, Jill. The checkbox is set to visible, and it works fine with mouse. The problem is when I use keyboard, the KeyPress event for the checkbox does not fire. I have the same code attached the KeyPress. But it does not get executed.
>>
>>Here is what I did in my checkbox:
>>
>>I create a MyCheckBox class, in which a checkbox is wrapped by a container. In the init method of the contain, I have the similar code as you listed: set the left and top of the checkbox, as well as the controlsource. In the checkbox, I set the Click and KeyPress code to update the underline field value and control key pressing.
>>
>>Then in the column's init, I have the following code:
>>
>>local nWidth, nHeight
>>nHeight = this.parent.rowheight
>>nWidth = this.width
>>this.addobject("SelectionCheckMark", "mycheckbox", nWidth, nHeight)
>>this.currentcontrol = 'SelectionCheckMark'
>>
>>Do you see anything wrong in my approach?
>>
>>WL
>
>No, sorry.
>
>I have a subclass of my grid class, w/the checkbox already added to the grid. Why don't you try that and see if it works for you...you might discover something new about your problem.
>
>J


I think I lost here. Do you say that you have a subclassed grid with a checkbox in its column? Is this checkbox wrapped by a container? Could you give me a little detail? Thanks.

WL
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform