⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11324.htm

📁 说明: column_list列出要添加数据的列名。在给表或视图中部分列添加数据时
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>看实例学VFP:页框控件的使用 - 编程入门网</title>
<meta name="keywords" content="看实例学VFP:页框控件的使用">
<meta name="description" content="看实例学VFP:页框控件的使用">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="/images/style.css" rel="stylesheet" type="text/css" />
<script src="/js1/head.js"></script>
</head>
<body leftmargin="0" topmargin="0" bgcolor="#efefef" oncopy=nocopy()>
<TABLE width="760" cellPadding="0" cellSpacing="0"  bgcolor="#eff7fe" align="center">
  <TR>
    <TD><a href="/index.htm"><img src="/images/logo1.gif" width="150" height="60" border="0"></a></TD>
    <TD width="470" align="right"><script src="/js1/top.js"></script></TD>
    <TD width="125" align="center"><script src="/js1/topsy.js"></script></TD>
  </TR>
</TABLE>
<table width="760" border="0" cellpadding="1" cellspacing="0" class="bklan" align="center">
  <tr>
    <td align="center" bgcolor="#eff7fe" height="24"> | <a href='/Programming/index.htm'>编程语言</a> | <a href='/webkf/index.htm'>web开发</a> | <a href='/data/index.htm'>数据库</a> | <a href='/Network/index.htm'>网络技术</a> | <a href='/OS/index.htm'>操作系统</a> | <a href='/Servers/index.htm'>服务器</a> | <a href='/web/index.htm'>网页设计</a> | <a href='/Design/index.htm'>图形设计</a> | <a href='/Office/index.htm'>办公软件</a> | <a href='/soft/index.htm'>常用软件</a> | <a href='/shadu/index.htm'>杀毒频道</a> | <a href='/PC/index.htm'>学电脑</a> |</td>
  </tr>
</table>
<table cellspacing="0" cellpadding="0" width="760" align="center" bgcolor="#ffffff" border="0">
  <tr>
    <td align="center"><script src="/js1/content1.js"></script></td>
  </tr>
</table>
<table width="760" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td height="25" background="/templets/img/31bg3.gif" align="left" class="guidet">&nbsp;→ 当前位置:<a href='http://www.bianceng.cn/'>首页</a>→<a href='/Programming/index.htm'>编程语言</a>→<a href='/Programming/vfp/index.htm'>vfp</a>→正文</td>
  </tr>
</table>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top" class="guidet" width="595"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="ct">
  <tr>
    <td align="center" valign="middle" class="til"><h3>&nbsp;&nbsp; 看实例学VFP:页框控件的使用 </h3>
      发布时间:2009-04-19 来源:编程入门网 作者:老马<br />
      <script src="/js1/468.js"></script>
    </td>
  </tr>
  <tr>
    <td style="font-size:14px" align="left" class="til"><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><script src="/js1/300.js"></script></td>
</tr>
</table><p>  页框(pageframe) 也是vfp的一个基本控件,使用它可以制作出类似于windows对话框的效果,关于这个控件的常用属性和方法请参考<a href="/vfpjc/chapter5/5-11.htm">vfp基础教程-页框和页</a>一文。 </p>
<p>  页框控件本身是一个容器,其中可以包含若干个页(page);而页也是容器,可以在其中添加各种对象,因此无论是在设计时添加对象或者是代码引用,都要比别的控件麻烦些。在使用这个控件时需要注意:如果设计时要向某个页中添加对象,一定要在页框的编辑状态下选中该页的标签,然后再向该页中添加控件;另外在不同页之间切换时,需要处理好数据源的问题。</p>
<p>  刚接触这个控件的同志可能经常会碰到这样一个问题:即使在页框中只设定了两页,这两页的标题宽度也会平均分配并且占满整个页框的宽度;而在标准windows对话框中,无论有多少页,页面标题都是左对齐排列的,如下图:</p>
<p><img height="440" alt="" width="401" border="0" src="/upimg/userup/0904/19114UQ560.jpg" /></p>
<p>  这个问题很好解决,把页框的TabStyle属性值设为&ldquo;1-非两端&rdquo;就可以出来这种左对齐的效果。</p>
<p>  本文来设计一个页框控件的应用实例,在本例中通过页框控件的两个页实现了<a href="/Programming/vfp/200902/11247.htm">看实例学VFP:对表中记录进行定位与查找操作</a>和<a href="/Programming/vfp/200902/11248.htm">看实例学VFP:向数据表中添加记录并验证输入数据是否合法</a>这两个例子的功能,运行时如下图:</p>
<p><img height="247" alt="" width="354" border="0" src="/upimg/userup/0904/19114933b45.jpg" /></p>
<p>  制作步骤如下:</p>
<p>  一、新建表单,将其caption属性值设置为&ldquo;编程入门网-页框控件&rdquo;,AutoCenter属性值设置为.t.,保存为&ldquo;表单1.scx&rdquo;。</p>
<p>  二、向表单上添加一个页框控件pageframe1,将其pagecount属性值设为2,TabStyle属性值设为&ldquo;1-非两端&rdquo;。</p>
<p>  三、右击页框控件选&ldquo;编辑&rdquo;命令,在页框的编辑状态下选中page1,将其caption属性值设置为&ldquo;查找记录&rdquo;,按照<a href="/Programming/vfp/200902/11247.htm">看实例学VFP:对表中记录进行定位与查找操作</a>一文向page1添加相同的控件并为各个控件设置相同的属性。</p>
<p>  四、在页框的编辑状态下选中page2,将其caption属性值设置为&ldquo;添加记录&rdquo;,按照<a href="/Programming/vfp/200902/11248.htm">看实例学VFP:向数据表中添加记录并验证输入数据是否合法</a>一文向page2添加相同的控件并为各个控件设置相同的属性。</p>
<p>  五、设置完毕后的表单设计器如下图:</p>
<p><img height="360" alt="" width="524" border="0" src="/upimg/userup/0904/1911495433c.jpg" /></p>
<p>  六、添加事件代码:</p>
<p>  (一)表单的init事件代码:</p>
<pre>&amp;&amp; coded by www.bianceng.cn
this.MaxButton=.f. &amp;&amp;屏蔽表单的最大化按钮
this.MinButton=.f. &amp;&amp;屏蔽表单的最小化按钮
this.pageframe1.activepage=2 &amp;&amp;指定第二页为当前页
set exact on
use 网站信息表
this.pageframe1.page1.combo1.value=&quot;编号&quot;
with this.pageframe1.page1.grid1
    .width=290
    .height=100
    .left=0
    .top=0
    .recordsource=&quot;网站信息表&quot;
    .deletemark=.f.
    .visible=.t.
    .readonly=.t.
    .ColumnCount=3
    .Column1.Header1.Caption=&quot;编号&quot;
    .Column1.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.Caption=&quot;网站名称&quot;
    .Column3.Header1.BackColor=RGB(255,255,190)
    .Column3.Header1.Caption=&quot;网站网址&quot;
    .Column1.width=75
    .Column2.width=80
    .Column3.width=150
endwith
with this.pageframe1.page2.grid1
    .width=290
    .height=100
    .left=0
    .top=0
    .recordsource=&quot;网站信息表&quot;
    .deletemark=.f.
    .visible=.t.
    .readonly=.t.
    .ColumnCount=3
    .Column1.Header1.Caption=&quot;编号&quot;
    .Column1.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.Caption=&quot;网站名称&quot;
    .Column3.Header1.BackColor=RGB(255,255,190)
    .Column3.Header1.Caption=&quot;网站网址&quot;
    .Column1.width=75
    .Column2.width=80
    .Column3.width=150
endwith
this.pageframe1.page1.grid1.Setall(&quot;DynamicBackColor&quot;,&quot;RGB(224,225,255)&quot;,&quot;Column&quot;)
this.pageframe1.page2.grid1.Setall(&quot;DynamicBackColor&quot;,&quot;RGB(224,225,255)&quot;,&quot;Column&quot;)
</pre>
<p>  (二)表单的unload事件代码:</p>
<p>close all<br />set exact off</p>
<p>  (三)page1(&ldquo;查找记录&rdquo;)中各对象的事件代码:</p>
<p>  1、page1的Activate事件代码:</p>
<p>  this.refresh</p>
<p>  2、&ldquo;查找&rdquo;按钮command1的click事件代码:</p>
<pre>if empty(thisform.pageframe1.page1.Text1.value)=.f.
go top
a=thisform.pageframe1.page1.Combo1.value
b=alltrim(thisform.pageframe1.page1.Text1.value)
  if a=&quot;编号&quot;
     locate for 编号=b
     if eof()
        messagebox(&quot;数据库中不存在您所要查询的记录&quot;,16,&quot;系统提示&quot;)
     else
        go recno()
     endif
  endif
  if a=&quot;网站名称&quot;
     locate for 网站名称=b
     if eof()
        messagebox(&quot;数据库中不存在您所要查询的记录&quot;,16,&quot;系统提示&quot;)
     else
        go recno()
     endif
  endif
  if a=&quot;网站网址&quot;
     locate for 网站网址=b
     if eof()
        messagebox(&quot;数据库中不存在您所要查询的记录&quot;,16,&quot;系统提示&quot;)
     else
        go recno()
     endif
  endif
  thisform.pageframe1.page1.grid1.setfocus
else
   messagebox(&quot;请输入要查找的内容!&quot;,16,&quot;系统提示&quot;)
   thisform.pageframe1.page1.Text1.value=&quot;&quot;
   thisform.pageframe1.page1.Text1.Setfocus
endif
return</pre>
<p>  3、&ldquo;恢复&rdquo;按钮command2的click事件代码:</p>
<pre>go top
thisform.pageframe1.page1.Text1.value=&quot;&quot;
thisform.pageframe1.page1.Text1.Setfocus
with thisform.pageframe1.page1.grid1
    .width=290
    .height=100
    .left=0
    .top=0
    .recordsource=&quot;网站信息表&quot;
    .visible=.t.
    .readonly=.t.
    .ColumnCount=3
    .Column1.Header1.Caption=&quot;编号&quot;
    .Column1.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.Caption=&quot;网站名称&quot;
    .Column3.Header1.BackColor=RGB(255,255,190)
    .Column3.Header1.Caption=&quot;网站网址&quot;
    .Column1.width=75
    .Column2.width=80
    .Column3.width=150
endwith
thisform.pageframe1.page1.grid1.Setall(&quot;DynamicBackColor&quot;,&quot;RGB(224,225,255)&quot;,&quot;Column&quot;)
thisform.pageframe1.page1.refresh</pre>
<p>  (四)page2(&ldquo;添加记录&rdquo;)中各对象的事件代码:</p>
<p>  1、page2的Activate事件代码:</p>
<p>  this.refresh</p>
<p>  2、&ldquo;添加&rdquo;按钮command1的click事件代码:</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -