Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox stays readonly

Status
Not open for further replies.

SuperBob

Technical User
Sep 18, 2001
23
GB
I've subclassed Checkbox to create class "Mycheck", in order to add an Interactivechange. I've then used addobject in my form to add Mycheck in a grid column, removing the Text1 object that is there by default. I set the Sparse and CurrentControl settings as usual.

However, when I run the form, the resulting checkbox is readonly. I tried adding a command to set the readonly property of the checkbox to False, but this makes no difference.

I don't understand what is going on.
 
HI

Try this example :)
Save it as a Prg and DO savedPrg from command window.
*************************************************
CREATE CURSOR test (cName C(20), lCurrent L)
INSERT INTO test (cName, lCurrent) VALUES ("experts",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("Dummy",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("ClayHead",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("WoodBrain",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("IronHead",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("BigHead",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("ShowMan",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("NutHead",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("Ramani",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("Mike",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("Rick",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("Chris",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("Dsumzz",.t.)
INSERT INTO test (cName, lCurrent) VALUES ("mySelf",.t.)
INDEX ON cName TAG cName
SET ORDER TO 1
LOCATE
** All above is code for a table for our example
****************************************************
myFields = "cName,lCurrent"
DO gsFindForm WITH myFields
=MESSAGEBOX("You have selected :"+ ;
ALLTRIM(cName), 0+16, "Eureka!")
RETURN
**************************************************
PROCEDURE gsFindForm
PARAMETERS tcFields

IF PARAMETERS() < 1
RETURN .f.
ENDIF

PUBLIC oform1

oform1=NEWOBJECT(&quot;gsFindForm&quot;,'','',tcFields)
oform1.Show

RELEASE oForm1
RETURN
**************************************************
*-- Form: gsFindForm
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS gsFindForm AS form

AutoCenter = .t.
Height = 242
Width = 420
DoCreate = .T.
Caption = &quot;FindForm&quot;
Name = &quot;gsFindForm&quot;
ShowTips = .t.
WindowType = 1
inrecno = 0
cFilter = &quot;&quot;
cFilterOld = &quot;&quot;

ADD OBJECT label1 AS Label WITH ;
Left = 12, ;
Top = 196, ;
Width = 78, ;
Caption = &quot;Search For&quot;, ;
Name = &quot;Label1&quot;

ADD OBJECT text1 AS textbox WITH ;
Height = 23, ;
Left = 84, ;
Top = 192, ;
Width = 400, ;
Name = &quot;Text1&quot;, ;
ToolTipText = &quot;Case sensitive.. &quot; + ;
&quot;Start with * and learn how it searches&quot;

ADD OBJECT cmdfirst AS commandbutton WITH ;
Top = 216, ;
Left = 0, ;
Height = 27, ;
Width = 84, ;
Caption = &quot;\<First&quot;, ;
Name = &quot;cmdFirst&quot;

ADD OBJECT cmdprevious AS commandbutton WITH ;
Top = 216, ;
Left = 84, ;
Height = 27, ;
Width = 84, ;
Caption = &quot;\<Previous&quot;, ;
Name = &quot;cmdPrevious&quot;

ADD OBJECT cmdnext AS commandbutton WITH ;
Top = 216, ;
Left = 168, ;
Height = 27, ;
Width = 84, ;
Caption = &quot;\<Next&quot;, ;
Name = &quot;cmdNext&quot;

ADD OBJECT cmdlast AS commandbutton WITH ;
Top = 216, ;
Left = 252, ;
Height = 27, ;
Width = 84, ;
Caption = &quot;\<Last&quot;, ;
Name = &quot;cmdLast&quot;

ADD OBJECT cmdexit AS commandbutton WITH ;
Top = 216, ;
Left = 336, ;
Height = 27, ;
Width = 84, ;
Cancel = .T., ;
Caption = &quot;E\<xit&quot;, ;
Name = &quot;cmdExit&quot;

ADD OBJECT grid1 AS grid WITH ;
Height = 192, ;
Left = 0, ;
Top = 0, ;
Width = 420, ;
Name = &quot;Grid1&quot;
DeleteMark = .F.
HighlightRow = .T.
ReadOnly = .T.
ForeColor = RGB(0,0,0)
BackColor = RGB(255,255,192)
GridLineColor = RGB(0,0,128)

PROCEDURE Init
PARAMETERS tcFields
IF PARAMETERS() < 1
RETURN .f.
ENDIF
LOCAL nCount
nCount = ALINES(laFields,tcFields,&quot;,&quot;)
WITH ThisForm.Grid1
.ColumnCount = nCount

** just added for checkbox example..
** The checkBox is added as Text1
** ... to avoid an error in AfterRowCol Change event
.Visible = .f.
WITH .Column2
.RemoveObject(&quot;Text1&quot;)
.AddObject(&quot;Text1&quot;,&quot;CheckBox&quot;)
.Sparse = .f.
ENDWITH
.Visible = .t.
**
FOR I=1 TO nCount
.Columns(I).ControlSource = laFields(i)
ENDFOR
.SetFocus()
ENDWITH
ENDPROC

PROCEDURE cmdfirst.Click
GO TOP
ThisForm.Grid1.SetFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cmdprevious.Click
IF NOT BOF()
SKIP -1
ENDIF
ThisForm.Grid1.SetFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cmdnext.Click
IF NOT EOF()
SKIP
ENDIF
ThisForm.Grid1.SetFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cmdlast.Click
GO BOTTOM
ThisForm.Grid1.SetFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cmdexit.Click
ThisForm.Release()
ENDPROC

PROCEDURE Text1.INTERACTIVECHANGE
LOCAL cFilterOld, cFilterIn
cFilterOld = ThisForm.cFilterOld
cFilterIn = KEY()
SET FILTER TO

IF LEFT(This.Value,1) = &quot;*&quot;
IF LEN(ALLTRIM(This.Value)) > 1
ThisForm.cFilter = ;
RIGHT(ALLTRIM(This.Value), ;
LEN(ALLTRIM(This.Value))-1)
IF EMPTY(cFilterOld)
SET FILTER TO ThisForm.cFilter $ &cFilterIn
ELSE
SET FILTER TO &cFilterOld .AND. ;
ThisForm.cFilter $ &cFilterIn
ENDIF
LOCATE
ELSE
IF !EMPTY(cFilterOld)
SET FILTER TO &cFilterOld
ENDIF
ENDIF
ELSE
IF !EMPTY(cFilterOld)
SET FILTER TO &cFilterOld
ENDIF
SEEK ALLT(This.Value)
ENDIF
ThisForm.Grid1.SetFocus
ThisForm.Text1.SetFocus
ThisForm.Refresh()
ENDPROC

PROCEDURE Grid1.AfterRowColChange
LPARAMETERS nColIndex
ThisForm.inRecNo = IIF(EOF() OR BOF(),0,RECNO())
This.Columns(This.ActiveColumn).Text1.BackColor = ;
RGB(255,0,0)
This.Columns(This.ActiveColumn).Text1.DisabledBackColor = ;
RGB(32,224,224)
This.Columns(This.ActiveColumn).Text1.DisabledForeColor = RGB(0,0,0)
This.Refresh()
ThisForm.Text1.SetFocus()
RETURN .T.
ENDPROC

PROCEDURE Grid1.Init
WITH This
.SetAll(&quot;BackColor&quot;, RGB(255,192,192),&quot;Header&quot;)
.SetAll(&quot;Alignment&quot;, 2, &quot;Header&quot;)
.SetAll(&quot;DynamicBackColor&quot;, ;
&quot;IIF(recno(This.RecordSource)= ;
ThisForm.inRecno,RGB(32,224,224), ;
RGB(255,255,192))&quot;,&quot;COLUMN&quot;)
ENDWITH
DODEFAULT()
ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
**************************************************
:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
SuperBob

However, when I run the form, the resulting checkbox is readonly. I tried adding a command to set the readonly property of the checkbox to False, but this makes no difference.

I think your solution is to make the checkbox visible believe or not.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top