| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1130 人关注过本帖, 1 人收藏
标题:请教Grid内插入Command问题
只看楼主 加入收藏
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:20 
程序代码:
CLEAR ALL
CLOSE DATABASES ALL
SET DEFAULT TO (Application.ActiveProject.HomeDir)
Form1 = NEWOBJECT("C_Form")
Form1.Show
READ EVENTS
CLOSE DATABASES ALL
CLEAR ALL
RETURN 

DEFINE CLASS C_Form AS Form
    Caption = "自定义按钮测试"
    WindowState = 2
   
    ADD OBJECT Grid1 AS Grid
   
    PROCEDURE Load
        USE Table1 IN 0
    ENDPROC
   
    PROCEDURE Unload
        USE IN Table1
    ENDPROC
   
    PROCEDURE Arrange
        WITH This.Grid1
            .Top = 5
            .Left = 5
            .Width = ThisForm.Width - .Left - 5
            .Height = ThisForm.Height - .Top - 5
        ENDWITH
    ENDPROC
   
    PROCEDURE Activate
        ThisForm.Arrange
    ENDPROC
   
    PROCEDURE Resize
        ThisForm.Arrange
    ENDPROC
   
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
    PROCEDURE Grid1.Init
        WITH This
            .RecordSourceType = 1
            .RecordSource = "Table1"
            WITH .Columns(3)
                .RemoveObject("Text1")
                .AddObject("Button1", "GridCommandButton")
                WITH .Button1
                    .ControlSource = "Table1.F03"
                    .TrueCaption = "Yes"
                    .FalseCaption = "No"
                    .Width = 60
                    .Height = 20
                    .Visible = .T.
                ENDWITH
                .CurrentControl = "Button1"
                .Sparse = .F.
                .Width = 60
            ENDWITH
            .RowHeight = 22
        ENDWITH
    ENDPROC
   
ENDDEFINE 

DEFINE CLASS GridCommandButton AS Container
    BorderWidth = 0

    ControlSource = ""
    TrueCaption = "是"
    FalseCaption = "否"
   
    ADD OBJECT Text1 AS TextBox WITH Visible = .F.
    ADD OBJECT Button1 AS CommandButton
   
    PROCEDURE Width_Assign(tAssign)
        This.Button1.Width = tAssign
    ENDPROC
   
    PROCEDURE Height_Assign(tAssign)
        This.Button1.Height = tAssign
    ENDPROC
   
    PROCEDURE ControlSource_Assign(tAssign)
        This.Text1.ControlSource = tAssign
    ENDPROC
   
    PROCEDURE Text1.Value_Assign(tAssign)
        This.Value = tAssign
        WITH This.Parent.Button1
            .Caption = IIF(tAssign, This.Parent.TrueCaption, This.Parent.FalseCaption)
            .VisualEffect = IIF(tAssign, 2, 1)
        ENDWITH
    ENDPROC
   
    PROCEDURE Button1.Click
        WITH This.Parent.Text1
            .Value = !.Value
        ENDWITH
    ENDPROC
   
ENDDEFINE

授人以渔,不授人以鱼。
2012-07-02 02:59
快速回复:请教Grid内插入Command问题
数据加载中...
 
   



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

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