| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    想学好编程,学好外语很重要  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> 应用开发 >> vb >> 控件 >> 文章正文
如何动态设定TextBox的靠左、右、中            【字体:
如何动态设定TextBox的靠左、右、中
作者:-    文章来源:-    点击数:    更新时间:2006-6-10

其实这是不可能一下子完成的,因为Alignment属性是唯读的,所以只好在Form中
使用三个TextBox来完成,Text1.Alignment = 0, Text2.Alignment = 1,
Text3.Alignment = 2,而且三者的MultiLine设为True。
并在Form中放三个Option Control,一开始Text2, Text3 Move到Text1的位置与大小,
而後看选择哪个Option会来决定何者Display出来,而达效果

Option Explicit

Private Sub Form_Load()

Text2.Visible = False
Text3.Visible = False
Text2.Move Text1.Left, Text1.Top, Text1.Width, Text1.Height
Text3.Move Text1.Left, Text1.Top, Text1.Width, Text1.Height
Text2.Text = Text1.Text
Text3.Text = Text1.Text
End Sub

Private Sub Option1_Click()
If Option1.Value = True Then
   Text1.Visible = True
   Text2.Visible = False
   Text3.Visible = False
End If

End Sub

Private Sub Option2_Click()
If Option2.Value = True Then
   Text2.Visible = True
   Text1.Visible = False
   Text3.Visible = False
End If

End Sub

Private Sub Option3_Click()
If Option3.Value = True Then
   Text3.Visible = True
   Text1.Visible = False
   Text2.Visible = False
End If

End Sub

Private Sub Text1_Change()
Text2.Text = Text1.Text
Text3.Text = Text1.Text
End Sub

Private Sub Text2_Change()
Text1.Text = Text2.Text
Text3.Text = Text2.Text

End Sub

Private Sub Text3_Change()
Text1.Text = Text3.Text
Text2.Text = Text3.Text

End Sub
 

[1]

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • 用VB编写DirectX7.0游戏(下…

  • 用VB编写DirectX7.0游戏(上…

  • 使用OLE DB和ADO调用返回记录…

  • 使用VB调用Oracle程序包内的…

  • VB中用ADO对象动态创建数据库…

  • fffff

  • 如何用MSComm Control传Bina…

  • MultiLink的WinSock Server程…

  • 用VB制作浏览器

  • 用VB编写网络寻呼机

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |