Link to home
Start Free TrialLog in
Avatar of jinfeld
jinfeldFlag for United States of America

asked on

checkbox in a runtime grid fails inside a bigger app

Hi,
I created a "simple" run-time grid. When I tested it out as a stand alone routine it works well. When I tried to integrate into a bigger app, where the READ EVENTS is initiated higher up in the program, and it uses many custom baseclasses under VFP 8 the checkbox generates the error: Error with CHK1 - Value : Data type mismatch.  
Note: I also tried this using a separate DEFINE for chk1 and it didn't help

Bonus question – how do you prevent the “delete” column from appearing in the grid – that little half-column on the left edge that you can click to delete a record.

Here is the abbreviated code:
******************************************
SELECT ac_tracknos
PUBLIC go_tracknolist
=l_doform()
RETURN

******************************************
FUNCTION l_doform

go_tracknolist = CREATEOBJECT("tracknolist")
go_tracknolist.show()

DEFINE CLASS tracknolist as Form
  WINDOWTYPE = 1  &&modal
  visible = .t.
  ShowWindow = 1
  Caption = "Tracking Numbers"
  Height = 305
  Width = 640
  fn_botrow = 258

  PROCEDURE init()
    WITH THIS
      .ADDOBJECT('cmdCancel', 'cCancel' )
      .cmdCancel.VISIBLE = .T.
      .AddObject("grid1","cgrid")
      .grid1.visible = .t.
    ENDWITH
  ENDPROC

ENDDEFINE
DEFINE CLASS cgrid AS Grid
   Left = 12
   Top = 10
   Width = 615
   Height = 245
   Visible = .T.
   RowHeight = 25
   ColumnCount = 2
   Column1.ControlSource ="seltd"
   Column2.ControlSource ="trackno"
   Column1.Sparse = .F.
  Procedure Init
     THIS.Column1.Width = 52
     THIS.Column2.Width = 175
     &&replace column1 with a checkbox
     THIS.Column1.AddObject("chk1", "checkbox")
     THIS.Column1.CurrentControl = "chk1"
     THIS.Column1.chk1.Visible = .T.
     THIS.Column1.chk1.Caption = ""
  ENDPROC

ENDDEFINE

DEFINE CLASS cCancel AS COMMANDBUTTON
  CANCEL = .T.  
  CAPTION = "\<Cancel"
  HEIGHT = 25

  PROCEDURE init()
    this.TOP = thisform.fn_botrow + 18
    this.LEFT = thisform.WIDTH - this.WIDTH - 5
  ENDPROC
     
  PROCEDURE CLICK
    USE IN "ac_tracknos"  
    go_tracknolist.RELEASE
  ENDPROC
ENDDEFINE
******************************************
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

This kind of grid will only work for recordsources having a logical field in the first field, otherwise of course you get the error "data type mismatch" A Checkbox cannot dislpay text, numbers (despite 0 and 1 also work like .F. and .T.)

The deletion column is called deletion mark, grid.deletemark = .f. get's rid of that column.

Bye, Olaf.
Avatar of jinfeld

ASKER

The first column is logical - that is why it works when I run it outside the larger app.

The table, ac_tracknos has 2 fields:
seltd L(1)
trackno C(50)
If there is no error but something like this happen in more complex environment then your only chance is to try to program it different way... The only possibility seems to be to create this small form visually in Form designer and call it by DO FORM instead of CREATEOBJECT.

The first attempt, of course, should be to test it under the latest VFP version (VFP9 SP2). Maybe it will work.

And the last possibility is ask Microsoft for a paid hotfix.

A new FoxPro version should also come. But not from Microsoft and not this year.
Avatar of jinfeld

ASKER

Thanks,
Is there a way to use the run-time code to populate a form or do I need to do it manually?
ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, I did not read Olaf's answer till the end. He answered the bonus question already.