Forms 基于Visual Foxpro数据网格的输入屏幕窗体

Forms 基于Visual Foxpro数据网格的输入屏幕窗体,forms,datagrid,visual-foxpro,Forms,Datagrid,Visual Foxpro,我有三张桌子,第一张是派对名称,第二张是品质,第三张是 存储采购订单。目前,我开发了带有文本框的订单输入表单。 当我在同一日期收到一方10或20多个不同质量的订单时,很难输入订单。 现在我想把它放到网格中。首先选择日期,然后选择参与方,然后输入所需数量的订单。但我不知道如何在VisualFoxPro中实现这一点。我努力寻找一些样品或例子,但没有找到。还有一件事我想在这里提到的是,这是我的4个表单应用程序中唯一的一个表单。我需要知道如何在网格中进行计算 请提供帮助。在VFP命令窗口中,打开任务窗格

我有三张桌子,第一张是派对名称,第二张是品质,第三张是 存储采购订单。目前,我开发了带有文本框的订单输入表单。 当我在同一日期收到一方10或20多个不同质量的订单时,很难输入订单。 现在我想把它放到网格中。首先选择日期,然后选择参与方,然后输入所需数量的订单。但我不知道如何在VisualFoxPro中实现这一点。我努力寻找一些样品或例子,但没有找到。还有一件事我想在这里提到的是,这是我的4个表单应用程序中唯一的一个表单。我需要知道如何在网格中进行计算


请提供帮助。

在VFP命令窗口中,打开任务窗格管理器并选择解决方案示例。搜索网格,你会发现一堆关于使用网格的例子。

像这样的

createtables()
ON ERROR 
oForm = CREATEOBJECT("myform")
oForm.visible = .t. 
READ EVENTS  
DEFINE CLASS mygrid as grid
    PROCEDURE init
        this.top = 40
        this.Left = 10
        this.Width = 450 
        this.ColumnCount = 6
        this.DeleteMark = .f.
        this.RecordMark = .f.
        this.RecordSource = "porders"
        this.column1.ControlSource = this.RecordSource + ".podate" 
        this.column1.Header1.Caption = "PO Date"
        this.column1.width = 75     
        this.column2.ControlSource = this.RecordSource + ".ponum" 
        this.column2.Header1.Caption = "PO Num"
        this.column2.width = 65
        this.column3.ControlSource = this.RecordSource + ".poparty"         
        this.column3.Header1.Caption = "Party"
        this.column3.width = 65
        this.column4.ControlSource = this.RecordSource + ".poqty" 
        this.column4.Header1.Caption = "Qty"
        this.column4.width = 65
        this.column5.ControlSource = this.RecordSource + ".poprice"
        this.column5.Header1.Caption = "Price"
        this.column5.width = 65
        this.column6.addobject("oqualities", "myqualities")
        this.column6.CurrentControl = "oqualities"
        this.column6.width = 65
        this.column6.sparse = .t.
        this.column6.Header1.Caption = "Quality"
        this.column6.ControlSource = this.RecordSource + ".poquality"       
    ENDPROC 
ENDDEFINE 
DEFINE class mycombo as combobox
    PROCEDURE init
        this.top = 10
        this.left = 150 
        this.Style = 2 
        this.RowSource = "parties.name"
        this.RowSourceType = 6       
    ENDPROC     
    PROCEDURE interactivechange
        SELECT (this.Parent.oGrid.RecordSource)
        lcVal = ["] + ALLTRIM(this.value) + ["]
        SET FILTER TO ALLTRIM(poparty) = &lcVal     
        this.Parent.ogrid.refresh()
    ENDPROC 
ENDDEFINE 
DEFINE class myqualities as combobox
    PROCEDURE init
        this.Style = 2
        this.RowSource = "qualities.desc"
        this.RowSourceType = 6      
    ENDPROC     
ENDDEFINE 
DEFINE CLASS mybutton as commandbutton
    PROCEDURE init
        LPARAMETERS tcMode
        this.Caption = tcMode
        this.Top = 250
        this.Left = 10
    ENDPROC  
    PROCEDURE click     
        IF this.Caption == "ADD"
            IF EMPTY(ALLTRIM(this.Parent.oparties.value))
                MESSAGEBOX("Please select party")
                RETURN .f.
            ENDIF 
            SELECT (this.Parent.ogrid.recordsource)         
            APPEND BLANK

            replace podate WITH this.parent.odate.value, ;
                    ponum WITH INT(RAND()*100000), ;
                    poparty WITH this.Parent.oparties.value, ;
                    poqty WITH 1                    

            this.Parent.ogrid.setfocus()
        ENDIF 
    ENDPROC 
ENDDEFINE  
DEFINE CLASS mydate as TextBox
    PROCEDURE init
        this.Value = DATE()
        this.Left = 10  
        this.Top = 10
    ENDPROC 
ENDDEFINE 
DEFINE CLASS myform as form
    PROCEDURE init
        this.AddObject("ogrid", "mygrid")
        this.AddObject("odate", "mydate")
        this.AddObject("oparties", "mycombo")
        this.AddObject("oAdd", "mybutton", "ADD")               
        this.ogrid.visible = .t.
        this.oparties.visible = .t.
        this.oAdd.visible = .t. 
        this.odate.visible = .t.        
        this.Height = 300
        this.Width = 470
        this.Visible = .t.
    ENDPROC 
ENDDEFINE 
PROCEDURE createtables
    IF !USED('parties')
        CREATE TABLE parties FREE (name c(20))
        INSERT INTO parties values("John")
        INSERT INTO parties values("Richard")
        INSERT INTO parties values("Melvin")
    ENDIF 
    IF !USED('qualities')
        CREATE TABLE qualities FREE (desc c(20))
        INSERT INTO qualities values("GOOD")
        INSERT INTO qualities values("BAD")
        INSERT INTO qualities values("SMELLY")
    ENDIF   
    IF !USED('porders')
        CREATE TABLE porders FREE (ponum i, podate D, poparty c(20), poqty n(10,2), poprice n(10,2), poquality c(20))
    ENDIF 
ENDPROC 

我试过了,但没有找到我想要的。还有一件事我想在这里提到,解决方案示例没有任何好的示例来学习数据网格编程。