| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1965 人关注过本帖
标题:求助:关于表修改的问题
只看楼主 加入收藏
zyangxiao
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2019-6-16
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:8 
求助:关于表修改的问题
新手求教。
问题1 如图,如何实现鼠标点到左表任一记录,在右侧文本框中对应显示相应记录,而不是用上一条或下一条记录挨个翻。
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


问题2 当我任选一条记录删除后,左表显示空白,如何在删除后让左表显示正常数据。
图片附件: 游客没有浏览图片的权限,请 登录注册

请各位大神帮忙找一下问题所在,谢谢!!!

PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


    **************************************************
*-- Form:         form1 (d:\vfp应用\学生成绩管理系统\form\f_user.scx)
*-- 父类:  form
*-- 基类:    form
*
DEFINE CLASS form1 AS form


    Height = 388
    Width = 602
    DoCreate = .T.
    AutoCenter = .T.
    Caption = "用户管理"
    Name = "Form1"


    ADD OBJECT shape2 AS shape WITH ;
        Top = 72, ;
        Left = 372, ;
        Height = 144, ;
        Width = 181, ;
        BackStyle = 0, ;
        SpecialEffect = 0, ;
        Name = "Shape2"


    ADD OBJECT shape1 AS shape WITH ;
        Top = 72, ;
        Left = 24, ;
        Height = 228, ;
        Width = 312, ;
        BackStyle = 0, ;
        SpecialEffect = 0, ;
        Name = "Shape1"


    ADD OBJECT grduser AS grid WITH ;
        ColumnCount = 3, ;
        Height = 200, ;
        Left = 42, ;
        RecordSource = "user", ;
        RecordSourceType = 1, ;
        Top = 86, ;
        Width = 276, ;
        Name = "grdUser", ;
        Column1.ControlSource = "user.账号", ;
        Column1.Name = "Column1", ;
        Column2.ControlSource = "user.真实姓名", ;
        Column2.Name = "Column2", ;
        Column3.ControlSource = "user.密码", ;
        Column3.Name = "Column3"


    ADD OBJECT form1.grduser.column1.header1 AS header WITH ;
        Caption = "账号", ;
        Name = "Header1"


    ADD OBJECT form1.grduser.column1.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grduser.column2.header1 AS header WITH ;
        Caption = "真实姓名", ;
        Name = "Header1"


    ADD OBJECT form1.grduser.column2.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grduser.column3.header1 AS header WITH ;
        Caption = "密码", ;
        Name = "Header1"


    ADD OBJECT form1.grduser.column3.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT txt账号 AS textbox WITH ;
        Comment = "", ;
        ControlSource = "user.账号", ;
        Enabled = .T., ;
        Height = 20, ;
        Left = 456, ;
        MaxLength = 10, ;
        TabIndex = 3, ;
        Top = 93, ;
        Width = 72, ;
        Name = "txt账号"


    ADD OBJECT lbl账号 AS label WITH ;
        AutoSize = .T., ;
        WordWrap = .T., ;
        BackStyle = 0, ;
        Caption = "账   号", ;
        Height = 16, ;
        Left = 394, ;
        Top = 95, ;
        Width = 42, ;
        TabIndex = 2, ;
        Name = "lbl账号"


    ADD OBJECT txt真实姓名 AS textbox WITH ;
        Comment = "", ;
        ControlSource = "user.真实姓名", ;
        Enabled = .T., ;
        Height = 20, ;
        Left = 456, ;
        MaxLength = 8, ;
        TabIndex = 5, ;
        Top = 132, ;
        Width = 72, ;
        Name = "txt真实姓名"


    ADD OBJECT lbl真实姓名 AS label WITH ;
        AutoSize = .T., ;
        WordWrap = .T., ;
        BackStyle = 0, ;
        Caption = "真实姓名", ;
        Left = 394, ;
        Top = 134, ;
        Width = 48, ;
        TabIndex = 4, ;
        Name = "lbl真实姓名"


    ADD OBJECT txt密码 AS textbox WITH ;
        Comment = "", ;
        ControlSource = "user.密码", ;
        Enabled = .T., ;
        Height = 20, ;
        Left = 456, ;
        MaxLength = 10, ;
        TabIndex = 7, ;
        Top = 169, ;
        Width = 72, ;
        Name = "txt密码"


    ADD OBJECT lbl密码 AS label WITH ;
        AutoSize = .T., ;
        WordWrap = .T., ;
        BackStyle = 0, ;
        Caption = "密   码", ;
        Height = 16, ;
        Left = 394, ;
        Top = 171, ;
        Width = 42, ;
        TabIndex = 6, ;
        Name = "lbl密码"


    ADD OBJECT command4 AS commandbutton WITH ;
        AutoSize = .F., ;
        Top = 312, ;
        Left = 504, ;
        Height = 30, ;
        Width = 60, ;
        FontSize = 11, ;
        Caption = "退出", ;
        Name = "Command4"


    ADD OBJECT command3 AS commandbutton WITH ;
        AutoSize = .F., ;
        Top = 312, ;
        Left = 432, ;
        Height = 30, ;
        Width = 60, ;
        FontSize = 11, ;
        Caption = "删除", ;
        Name = "Command3"


    ADD OBJECT command1 AS commandbutton WITH ;
        AutoSize = .F., ;
        Top = 312, ;
        Left = 288, ;
        Height = 30, ;
        Width = 60, ;
        FontSize = 11, ;
        Caption = "添加", ;
        Name = "Command1"


    ADD OBJECT commandgroup1 AS commandgroup WITH ;
        AutoSize = .F., ;
        ButtonCount = 4, ;
        Value = 1, ;
        Height = 35, ;
        Left = 336, ;
        Top = 252, ;
        Width = 265, ;
        Name = "Commandgroup1", ;
        Command1.AutoSize = .F., ;
        Command1.Top = 5, ;
        Command1.Left = 5, ;
        Command1.Height = 25, ;
        Command1.Width = 60, ;
        Command1.Caption = "首记录", ;
        Command1.Name = "Command1", ;
        Command2.AutoSize = .F., ;
        Command2.Top = 5, ;
        Command2.Left = 70, ;
        Command2.Height = 25, ;
        Command2.Width = 60, ;
        Command2.Caption = "末记录", ;
        Command2.Name = "Command2", ;
        Command3.AutoSize = .F., ;
        Command3.Top = 5, ;
        Command3.Left = 135, ;
        Command3.Height = 25, ;
        Command3.Width = 60, ;
        Command3.Caption = "上一条", ;
        Command3.Name = "Command3", ;
        Command4.AutoSize = .F., ;
        Command4.Top = 5, ;
        Command4.Left = 200, ;
        Command4.Height = 25, ;
        Command4.Width = 60, ;
        Command4.Caption = "下一条", ;
        Command4.Name = "Command4"


    ADD OBJECT command2 AS commandbutton WITH ;
        AutoSize = .F., ;
        Top = 312, ;
        Left = 360, ;
        Height = 30, ;
        Width = 60, ;
        FontSize = 11, ;
        Caption = "插入", ;
        Name = "Command2"


    PROCEDURE command4.Click
        thisform.release
    ENDPROC


    PROCEDURE command3.Click
        delete
        pack
        thisform.refresh
    ENDPROC


    PROCEDURE command1.Click
        append blank
        goto bottom
        thisform.refresh
    ENDPROC


    PROCEDURE
        go top
        this.enabled=.F.
        
        
        
        thisform.refresh
    ENDPROC


    PROCEDURE
        go bottom
        this.enabled=.F.
        
        
        
        thisform.refresh
    ENDPROC


    PROCEDURE
        skip-1
        if bof()
           messagebox("已是第一条记录",48,"信息窗口")
           this.enabled=.F.
           
           
           
        else
           this.enabled=.T.
           
           
           
          thisform.refresh
        endif
    ENDPROC


    PROCEDURE
        skip 1
        if eof()
           messagebox("已是最后一条记录",48,"信息窗口")
           this.enabled=.F.
           
           
           
        else
           this.enabled=.T.
           
           
           
          thisform.refresh
        endif
    ENDPROC


    PROCEDURE command2.Click
        insert before blank
        thisform.refresh
    ENDPROC


ENDDEFINE
*
*-- 结束定义: form1
**************************************************
搜索更多相关主题的帖子: OBJECT Name ADD WITH thisform 
2019-06-20 09:40
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:4 
可以在Grid的AfterRowColChange事件中处理
2019-06-20 10:16
xuminxz
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:41
帖 子:766
专家分:2517
注 册:2011-5-8
收藏
得分:4 
楼主常用Java或其它非可视化的语言?VFP定义表单与控件没这么麻烦。
如2楼所说,VFP的事件、属性足够多一般不用自己定义的。


dBase有人接盘了。
2019-06-20 10:33
zyangxiao
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2019-6-16
收藏
得分:0 
请问Grid的AfterRowColChange事件中怎么处理?
2019-06-20 13:45
gs2536785678
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:45
帖 子:610
专家分:1784
注 册:2017-7-16
收藏
得分:4 
朋友,看过你的对话,在VF中,一般窗口不用代码完成,而是直接可视化用现成的

[请问Grid的AfterRowColChange事件中怎么处理?]
就是在这个事件中写入代码
找到指定记录,然后把记录内容展示在文本框里

说真的,看你代码创作窗口么,你是一个高手,但是看你在提出这样的初级问题么
你还是个学徒。

[此贴子已经被作者于2019-6-21 08:31编辑过]

2019-06-21 08:21
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:0 
以下是引用zyangxiao在2019-6-20 13:45:15的发言:

请问Grid的AfterRowColChange事件中怎么处理?

简单参考示例:
图片附件: 游客没有浏览图片的权限,请 登录注册

****** test.prg ******
SET DELETED ON
CREATE CURSOR tt (f1 C(10), f2 I, f3 I)
FOR i = 1 TO 100
    INSERT INTO tt VALUES ("F"+PADL(i,4,"0"), i, 2*i)
ENDFOR
GO TOP
of = CREATEOBJECT("Form1")
of.Show(1)
RETURN

DEFINE CLASS Form1 As Form
    width = 500   
    ADD OBJECT grid1 as grid
    ADD OBJECT text1 as textbox WITH top=20,left=350
    ADD OBJECT text2 as textbox WITH top=50,left=350
    ADD OBJECT text3 as textbox WITH top=80,left=350
    ADD OBJECT cmd1 as commandbutton WITH top=110,left=350,height=22,caption="删除"
   
    PROCEDURE grid1.AfterRowColChange(nColIndex)
        thisform.text1.value = tt.f1
        thisform.text2.value = tt.f2
        thisform.text3.value = tt.f3
    ENDPROC
   
    PROCEDURE cmd1.click
        IF MESSAGEBOX("删除选定的数据记录",1+16+256,"提示")==1
            DELETE
        ENDIF
        thisform.grid1.setfocus
    ENDPROC
ENDDEFINE
2019-06-21 08:57
zyangxiao
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2019-6-16
收藏
得分:0 
各位大神,我是一个初学者,窗口是可视化设置的,只是功能按钮代码是自己编的,代码是从类浏览库中自动生成的,为了方便各位帮忙查找问题。
所以一些基础知识还不是太明白,自己自学很慢,慢慢摸索,还请各位大神多多指教。
问题再重复一下
问题1 如图,如何实现鼠标点到左表任一记录,在右侧文本框中对应显示相应记录,而不是用上一条或下一条记录挨个翻。
问题2 当我任选一条记录删除后,左表显示空白,如何在删除后让左表显示正常数据。
还请各位大神详细讲解,再次感谢!!
2019-06-21 09:03
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:0 
回复 7楼 zyangxiao
示例代码全部写入 test.prg 文件运行
tt是临时数据表,默认为grid1的数据源,字段顺序默认为grid1列顺序。
PROCEDURE grid1.AfterRowColChange(nColIndex) 相当于在表单中表格控件grid1的AfterRowColChange事件中写的代码过程
PROCEDURE cmd1.click 相当于在表单中按钮控件cmd1的Click事件中写的代码过程
2019-06-21 09:49
schtg
Rank: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1732
专家分:3329
注 册:2012-2-29
收藏
得分:4 
学习,谢谢!
2019-06-21 11:33
快速回复:求助:关于表修改的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024003 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved