Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record Input in Grid
Message
From
01/04/2010 07:38:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
31/03/2010 22:11:29
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01458173
Message ID:
01458326
Views:
137
>Hi,
>You mean I need to create a form class with data input format and add to the grid control,
>But how to add the form class to the grid control ?
>I find that it create a formset to my parent form.
>
>Please advise.
>
>Thank a lot.
>
>Derek

That is not exactly what I meant but sort of. Easier one is to simply set Grid's view property to 1.


Here it is step-by-step and also in code after the steps:

-Create a new temp form
Modify Form dummy && this is temp anyway [ENTER]
-Add customer to form's dataenvironment
-Select all the fields
-Using RIGHT mouse button drag & drop the fields on to form
-Arrange the fields a bit if you wish
-Select all controls (that you would like to see in grid cell) and File/Save as class (assuming you save as "MyCustomer" to "MyLib.vcx")
-You are done with this form, yoiu may continue on this form or another where your grid would be.
-If you are working on this one delete the controls and add a grid.
-Set grid recordsource to Customer and columncount to 1
-Resize the grid and then the grid column width, rowheight enough so that your saved container class would fit in
-Using books icon add MyLib.vcx to forms control toolbar
-Put grid in edit mode and select column1
-Select MyCustomer container control from controls toolbar and click on column, MyCustomer1 would be added to the column
-Using PEM sheet dropdown, select column1, set its CurrentControl to:
MyCustomer1
and Sparse to .F.
-You are done.

Here is a sample in code:
Public oForm
oForm = Createobject('SampleForm')
oForm.Show()

Define Class SampleForm As Form
  DataSession=2
  Height = 300
  Width = 520

  Add Object grdCustomer As Grid With ;
    RecordSource='Customer',ColumnCount=1,;
    DeleteMark=.F.,RecordMark=.F.,SplitBar=.F.,ScrollBars=2,;
    Height=300,Width=520,;
    HeaderHeight=0,RowHeight=300

  Procedure Load
    Set Multilocks On
    Use (_samples+'data\customer')
    CursorSetProp("Buffering",5,'Customer')
  Endproc

  Procedure Init
    With This.grdCustomer.Columns(1) As Column
      .AddObject('myCustomer','myCustomer')
      .CurrentControl = 'myCustomer'
      .Sparse = .F.
      .Width = 500
      .myCustomer.Visible = .T.
    Endwith
  Endproc
Enddefine

Define Class myCustomer As Container
  Width = 500
  Height = 300
  BackStyle = 0
  BorderWidth = 0

  Add Object lblcust_id As Label With ;
    Left = 0, Top = 0,  AutoSize = .T., BackStyle = 0, Caption = "Cust_id"

  Add Object txtcust_id As TextBox With ;
    Left = 70, Top = 0,  Width = 55, ControlSource = "customer.cust_id"

  Add Object lblcompany As Label With ;
    Left = 0, Top = 25,	AutoSize = .T., BackStyle = 0, Caption = "Company"

  Add Object txtcompany As TextBox With ;
    Left = 70, Top = 25,  Width = 280, ControlSource = "customer.company"

  Add Object lblcontact As Label With ;
    Left = 0, Top = 50,  AutoSize = .T., BackStyle = 0, Caption = "Contact"

  Add Object txtcontact As TextBox With ;
    Left = 70, Top = 50,  Width = 220, ControlSource = "customer.contact"

  Add Object lbltitle As Label With ;
    Left = 0, Top = 75,  AutoSize = .T., BackStyle = 0, Caption = "Title"

  Add Object txttitle As TextBox With ;
    Left = 70, Top = 75,  Width = 220, ControlSource = "customer.title"

  Add Object lbladdress As Label With ;
    Left = 0, Top = 100,  AutoSize = .T., BackStyle = 0, Caption = "Address"

  Add Object txtaddress As TextBox With ;
    Left = 70, Top = 100,  Width = 430, ControlSource = "customer.address"


  Add Object lblcity As Label With ;
    Left = 0, Top = 125,  AutoSize = .T., BackStyle = 0, Caption = "City"

  Add Object txtcity As TextBox With ;
    Left = 70, Top = 125,  Width = 120, ControlSource = "customer.city"

  Add Object lblregion As Label With ;
    Left = 0, Top = 150,  AutoSize = .T., BackStyle = 0, Caption = "Region"

  Add Object txtregion As TextBox With ;
    Left = 70, Top = 150,  Width = 120, ControlSource = "customer.region"

  Add Object lblpostalcode As Label With ;
    Left = 0, Top = 175,  AutoSize = .T., BackStyle = 0, Caption = "Postalcode"

  Add Object txtpostalcode As TextBox With ;
    Left = 70, Top = 175,  Width = 80, ControlSource = "customer.postalcode"

  Add Object lblcountry As Label With ;
    Left = 0, Top = 200,  AutoSize = .T., BackStyle = 0, Caption = "Country"

  Add Object txtcountry As TextBox With ;
    Left = 70, Top = 200,  Width = 115, ControlSource = "customer.country"

  Add Object lblphone As Label With ;
    Left = 0, Top = 225,  AutoSize = .T., BackStyle = 0, Caption = "Phone"

  Add Object txtphone As TextBox With ;
    Left = 70, Top = 225,  Width = 180, ControlSource = "customer.phone"

  Add Object lblfax As Label With ;
    Left = 0, Top = 250,  AutoSize = .T., BackStyle = 0, Caption = "Fax"

  Add Object txtfax As TextBox With ;
    Left = 70, Top = 250,  Width = 180, ControlSource = "customer.fax"

  Add Object lblmaxordamt As Label With ;
    Left = 0, Top = 275,  AutoSize = .T., BackStyle = 0, Caption = "Maxordamt"

  Add Object txtmaxordamt As TextBox With ;
    Left = 70, Top = 275,  Width = 70, ControlSource = "customer.maxordamt"
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform