• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi--自带控件(Tcheckbox、TComBobox、TpageControl、TDBGrid,TScrollBox,TEdit) ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

一、TCheckBox


使CheckBox选中CheckBox1.Checked := True;选择发生变化 ,OnClick事件
if CheckBox1.Checked thenbegin
//...选中要执行的代码endelse begin
//...未选中要执行的代码end;

 

二、TComBobox

1、添加
TComBobox就是下拉框,供选择用的.它有个Items属性,就是下拉的内容,你可以给它添加下拉内容.比如:

combobox1.Items.add('张三');
combobox1.Items.add('李四');

 

 

三、TpageControl

添加新页签:右击“New  Page”。修改页签名字:选择PageControl的单独某一标签(如:TabSheet1或TabSheet2),找到其Caption属性进行修改就可以了。

四、TDBGrid

选择行:TDBGrid属性properties面板,设置Options-->dgRowSelect及dgRowAlwaysShowSelection设为true;

选中TDBGrid一行,对应其数据集中的一行自动呈选中状态,可直接操作数据集,即操作的是所选中的行列数据,如:

str:=  DBGrid1.DataSource.DataSet.FieldByName('数据ID').Value ;

多选:options->dgMultiSelect:true

显示选中一行的样式:dgRowSelect:True

 

五、TScrollBox

1)清除里面里的控件

for i:=Self.ScrollBox1.ControlCount-1 downto 0 do 
  Self.ScrollBox1.Controls[i].Free;

 2)鼠标滚动

//Delphi为滚轮滚动提供OnMouseWheel事件

procedure
TFMW_010302_SJTBTX.scrlboxMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin if WheelDelta < 0 then SendMessage(scrlbox.Handle,WM_VSCROLL, SB_LINEDOWN, 0) //向下滚 else SendMessage(scrlbox.Handle,WM_VSCROLL, SB_LINEUP, 0); //向上滚 end;
//鼠标按下触发的事件,获取scrollbox的焦点
procedure
TFMW_010302_SJTBTX.scrlboxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin scrlbox.SetFocus end;

 

六、TEdit

1)只能输入数字

procedure TFrm_020101_devAdd.edt_sizeKeyPress(Sender: TObject; var Key: Char);
begin
    if not(Key in['0'..'9','.',#8]) then
    begin
        Key := #0;
    end;
end;

 




添加新页签:右击“New  Page”。修改页签名字:选择PageControl的单独某一标签(如:TabSheet1或TabSheet2),找到其Caption属性进行修改就可以了。

四、TDBGrid

选择行:TDBGrid属性properties面板,设置Options-->dgRowSelect及dgRowAlwaysShowSelection设为true;

选中TDBGrid一行,对应其数据集中的一行自动呈选中状态,可直接操作数据集,即操作的是所选中的行列数据,如:

str:=  DBGrid1.DataSource.DataSet.FieldByName('数据ID').Value ;

多选:options->dgMultiSelect:true

显示选中一行的样式:dgRowSelect:True

 

五、TScrollBox

1)清除里面里的控件

for i:=Self.ScrollBox1.ControlCount-1 downto 0 do 
  Self.ScrollBox1.Controls[i].Free;

 2)鼠标滚动

//Delphi为滚轮滚动提供OnMouseWheel事件

procedure
TFMW_010302_SJTBTX.scrlboxMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin if WheelDelta < 0 then SendMessage(scrlbox.Handle,WM_VSCROLL, SB_LINEDOWN, 0) //向下滚 else SendMessage(scrlbox.Handle,WM_VSCROLL, SB_LINEUP, 0); //向上滚 end;
//鼠标按下触发的事件,获取scrollbox的焦点
procedure
TFMW_010302_SJTBTX.scrlboxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin scrlbox.SetFocus end;

 

六、TEdit

1)只能输入数字

procedure TFrm_020101_devAdd.edt_sizeKeyPress(Sender: TObject; var Key: Char);
begin
    if not(Key in['0'..'9','.',#8]) then
    begin
        Key := #0;
    end;
end;

 




选择行:TDBGrid属性properties面板,设置Options-->dgRowSelect及dgRowAlwaysShowSelection设为true;

选中TDBGrid一行,对应其数据集中的一行自动呈选中状态,可直接操作数据集,即操作的是所选中的行列数据,如:

str:=  DBGrid1.DataSource.DataSet.FieldByName('数据ID').Value ;

多选:options->dgMultiSelect:true

显示选中一行的样式:dgRowSelect:True

 

五、TScrollBox

1)清除里面里的控件

for i:=Self.ScrollBox1.ControlCount-1 downto 0 do 
  Self.ScrollBox1.Controls[i].Free;

 2)鼠标滚动

//Delphi为滚轮滚动提供OnMouseWheel事件

procedure
TFMW_010302_SJTBTX.scrlboxMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin if WheelDelta < 0 then SendMessage(scrlbox.Handle,WM_VSCROLL, SB_LINEDOWN, 0) //向下滚 else SendMessage(scrlbox.Handle,WM_VSCROLL, SB_LINEUP, 0); //向上滚 end;
//鼠标按下触发的事件,获取scrollbox的焦点
procedure
TFMW_010302_SJTBTX.scrlboxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin scrlbox.SetFocus end;

 

六、TEdit

1)只能输入数字

procedure TFrm_020101_devAdd.edt_sizeKeyPress(Sender: TObject; var Key: Char);
begin
    if not(Key in['0'..'9','.',#8]) then
    begin
        Key := #0;
    end;
end;

 





鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap