您的位置:程序门 -> vb -> 控件



小女子先行谢过了~有关datagrid控件


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


小女子先行谢过了~有关datagrid控件[已结贴,结贴人:isabelle_plmm]
发表于:2007-05-26 09:53:54 楼主



          我想在datagrid控件中,锁定一行,注意,是一行,行!该怎么做?    
          先谢谢大伙了~~
发表于:2007-05-26 10:28:231楼 得分:5
用dbgrid吧
发表于:2007-05-30 16:46:552楼 得分:15
隻能進行列鎖定
给你一个在stringgrid中设置只读列的程序代码      
    dbgrid应该也差不多把      
    procedure       twork_plan.stringgrid2selectcell(sender:       tobject;       acol,      
            arow:       integer;       var       canselect:       boolean);      
    var      
            r:       trect;      
    begin      
            empolyee.visible:=false;      
            num.visible:=false;      
       
            with       sender       as       tstringgrid       do      
       
            if       trim(cells[4,arow])= ' '       then      
                        begin      
                                cells[3,arow]:= 'insert ';      
                                cells[4,arow]:= '0011 ';      
                        end;      
       
    with       sender       as       tstringgrid       do      
       
            if       (acol       =       1)       or       (acol       =       2)       and       (arow       > =       fixedrows)       then       //在第二列显示一个combobox      
            begin      
                    //取消选中模式      
                        perform(       wm_cancelmode,       0,       0       );      
       
                    //确定combobox的位置      
                        r       :=       cellrect(       acol,       arow       );      
       
                        if       acol=1       then      
                        with       empolyee       do      
                                        begin      
                                                setbounds(       r.left,       r.top,       r.right-r.left,       height       );      
                                                itemindex       :=       items.indexof(       cells[       acol,       arow       ]       );      
                                                show;      
                                                bringtofront;      
       
                                                //使得combobox称为输入的焦点      
                                                setfocus;      
       
                                                //droppeddown       :=       true;      
                                        end;      
       
                        if       acol=2       then      
                                        with       num       do      
                                        begin      
                                                setbounds(       r.left,       r.top,       r.right-r.left,       height       );      
                                                text:=cells[acol,arow];      
                                                show;      
                                                bringtofront;      
                                                setfocus;;      
                                                //使得combobox称为输入的焦点      
                                                //droppeddown       :=       true;      
                                        end;      
            end      
            else      
       
                    if       access[1]= '2 '       then      
                                    begin      
                                    if       acol=5       then      
                                                if       stringgrid2.cells[1,arow]=logon_user       then      
                                                            stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect,goediting,goalwaysshoweditor]      
                                                else      
                                                            stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect];      
       
                                    if       acol=6       then      
                                                //if       stringgrid2.cells[1,arow]=logon_user       then      
                                                stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect,goediting,goalwaysshoweditor];      
    //                                   else      
    //                                               stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect];      
       
                                    end;      
                        //设置哪个col为只读选项      
       
                    if       access[1]= '1 '       then      
                                    begin      
                                    if       (acol=5)       then      
                                                if       stringgrid2.cells[1,arow]=logon_user       then      
                                                            stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect,goediting,goalwaysshoweditor]      
                                                else      
                                                            stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect];      
       
                                    if       (acol=6)       then      
                                                stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect];      
       
                                    end;      
                        //设置哪个col为只读选项      
       
                if       access[1]= '3 '       then      
                            if       acol=5       then      
                            if       stringgrid2.cells[1,arow]=logon_user       then      
                                        stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect,goediting,goalwaysshoweditor]      
                            else      
                                        stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect];      
                            if       acol=6       then      
                                                                stringgrid2.options:=[gofixedvertline,gofixedhorzline,govertline,gohorzline,gorangeselect];      
    end;


快速检索

最新资讯
热门点击