小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Grid中嵌入CommandButton的自定義控件

 dds885 2016-03-30
程序代碼:
CLEAR ALL
CLOSE DATABASES ALL
SET DEFAULT TO (Application.ActiveProject.HomeDir)
Form1 = NEWOBJECT("C_Form")        && 從類(lèi)定義中C_Form中生成窗體
Form1.Show                         && 顯示剛才生成的窗體
READ EVENTS                        && 激活交互事件
CLOSE DATABASES ALL
CLEAR ALL
RETURN                             && 程序結(jié)束

*-----------------------------
* 程序運(yùn)行窗體的類(lèi)定義
*-----------------------------
DEFINE CLASS C_Form AS Form
    Caption = "自定義按鈕測(cè)試"     && 窗體標(biāo)題
    WindowState = 2                && 啟動(dòng)時(shí)最大化
   
    ADD OBJECT Grid1 AS Grid       && 在窗體中放置一個(gè)Grid
   
    *-------------------------
    * 窗體載入內(nèi)存時(shí)打開(kāi)相關(guān)的數(shù)據(jù)表
    *-------------------------
    PROCEDURE Load
        USE Table1 IN 0
    ENDPROC
   
    *-------------------------
    * 窗體從內(nèi)存中卸載時(shí)關(guān)閉已打開(kāi)的數(shù)據(jù)表
    *-------------------------
    PROCEDURE Unload
        USE IN Table1
    ENDPROC
   
    *-------------------------
    * 自定義對(duì)窗體的控件進(jìn)行布局的方法
    *-------------------------
    PROCEDURE Arrange
        WITH This.Grid1
            .Top = 5
            .Left = 5
            .Width = ThisForm.Width - .Left - 5
            .Height = ThisForm.Height - .Top - 5
        ENDWITH
    ENDPROC
   
    *-------------------------
    * 窗體激活或獲得焦點(diǎn)時(shí)
    *-------------------------
    PROCEDURE Activate
        ThisForm.Arrange
    ENDPROC
   
    *-------------------------
    * 窗體改變大小時(shí)
    *-------------------------
    PROCEDURE Resize
        ThisForm.Arrange
    ENDPROC
   
    *-------------------------
    * 關(guān)閉窗體時(shí)釋放交互事務(wù)
    *-------------------------
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
    *-------------------------
    * 表格的初始化
    *-------------------------
    PROCEDURE Grid1.Init
        WITH This
            .RecordSourceType = 1                               && 數(shù)據(jù)源為表別名
            .RecordSource = "Table1"                            && 綁定數(shù)據(jù)源
            WITH .Columns(3)                                    && 對(duì)具體數(shù)據(jù)表中的某列細(xì)化
                .RemoveObject("Text1")                          && 移除該欄中內(nèi)置的TextBox控件
                .AddObject("Button1", "GridCommandButton")      && 新增自定義控件
                WITH .Button1
                    .ControlSource = "Table1.F03"               && 綁定本欄的數(shù)據(jù)源
                    .TrueCaption = "Yes"                        && 修改預(yù)定義的文字
                    .FalseCaption = "No"                        && 修改預(yù)定義的文字
                    .Width = 60                                 && 設(shè)置控件寬度
                    .Height = 20                                && 設(shè)置控件高度
                    .Visible = .T.                              && 讓控件可見(jiàn)
                ENDWITH
                .CurrentControl = "Button1"                     && 設(shè)定本欄的控制控件
                .Sparse = .F.                                   && 每次Refresh時(shí)Grid所有行中本欄的數(shù)據(jù)均刷新
                .Width = 60                                     && 本欄的寬度與新控件匹配
            ENDWITH
            .RowHeight = 22                                     && 表格行的高度與新控件匹配
        ENDWITH
    ENDPROC
   
ENDDEFINE 

*-----------------------------
* 功能:嵌入Grid中的CommandButton,可與邏輯型數(shù)據(jù)綁定
* 機(jī)制:從Container中繼承,構(gòu)造一個(gè)包含隱藏TextBox和呈現(xiàn)CommandButton的
*       自定義控件。TextBox與平常Grid Cell的一樣綁定數(shù)據(jù),把需要提供的
*       數(shù)據(jù)轉(zhuǎn)交給CommandButton,以便呈現(xiàn)。
* 注意:數(shù)據(jù)綁定源須為邏輯型,否則失效或出錯(cuò)。
*-----------------------------
DEFINE CLASS GridCommandButton AS Container
    BorderWidth = 0           && 取消容器的邊框線

    *-------------------------
    * 自定義屬性
    ControlSource = ""        && 數(shù)據(jù)綁定源
    TrueCaption = "是"        && 當(dāng)數(shù)據(jù)值為.T.時(shí)CommandButton的文字
    FalseCaption = "否"       && 當(dāng)數(shù)據(jù)值為.F.時(shí)CommandButton的文字
    *-------------------------
   
    *-------------------------
    * 內(nèi)部受保護(hù)控件
    *-------------------------
    ADD OBJECT PROTECTED Text1 AS TextBox WITH Visible = .F.
    ADD OBJECT PROTECTED 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)
        WITH This.Text1
            .ControlSource = tAssign
            .Value = EVALUATE(tAssign)
        ENDWITH
    ENDPROC
   
    PROCEDURE Text1.Value_Assign(tAssign)
        This.Value = tAssign
        WITH This.Parent.Button1
            .VisualEffect = IIF(tAssign, 21)
            .Caption = IIF(This.Parent.Text1.Value, This.Parent.TrueCaption, This.Parent.FalseCaption)
        ENDWITH
    ENDPROC
   
    *-------------------------
    * 點(diǎn)擊按鈕時(shí)翻轉(zhuǎn)值的真假
    *-------------------------
    PROCEDURE Button1.Click
        WITH This.Parent.Text1
            .Value = !.Value
        ENDWITH
    ENDPROC
   
ENDDEFINE 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多