Solved

checkbox in a runtime grid fails inside a bigger app

Posted on 2011-09-14
6
855 Views
Last Modified: 2012-05-12
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
******************************************
0
Comment
Question by:jinfeld
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 36537741
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.
0
 

Author Comment

by:jinfeld
ID: 36537840
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)
0
 
LVL 41

Expert Comment

by:pcelba
ID: 36538150
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jinfeld
ID: 36538165
Thanks,
Is there a way to use the run-time code to populate a form or do I need to do it manually?
0
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
ID: 36538194
No, there is no way to populate the form from your code. At least I don't know it. But this form is very simple, so it is 10 minutes of work.

BTW, the answer to your bonus question is  Grid.DeleteMark property (.T. = display Delete column).
0
 
LVL 41

Expert Comment

by:pcelba
ID: 36538256
Sorry, I did not read Olaf's answer till the end. He answered the bonus question already.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now