Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

checkbox in a runtime grid fails inside a bigger app

Posted on 2011-09-14
6
890 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 42

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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 42

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 42

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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