Solved

checkbox in a runtime grid fails inside a bigger app

Posted on 2011-09-14
6
868 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

947 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

23 Experts available now in Live!

Get 1:1 Help Now