以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]工具条问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=86480)

--  作者:pcxjxjhkw
--  发布时间:2016/6/18 10:49:00
--  [求助]工具条问题

http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=62452

 

这是我原来写的一个在窗口中加入工具条的函数,只能实现横向工具条

现在:无法实现工具条纵向加入,求助大家.

 

谢谢

 

\'\'函数名:加入工具条和控件
\'\'用途:在窗口指定容器中动态添加工具条,并在工具条中加入控件
\'\'参数0:要添加的容器
\'\'参数1:要添加的控件,其控件事先加入并写好代码

如:AfterLoad事件
\'\'添加工具条及控件
Dim spl As WinForm.SplitContainer = e.Form.Controls("SplitContainer18")
Dim s() As String = {"复选","全选","反选","分隔条","查找:","查找关键词","查找","显示全部","高级查询","分隔条","第一页","上一页","页数","下一页","最末页","分隔条","每页:","每页条数","合计页数"}
Functions.Execute("添加工具条及控件",spl.Panel2,s)

望大家测试,并改良!


以下内容只有回复后才可以浏览


Dim ctr As WinForm.Control = Args(0) \'\'要添加工具条的容器
Dim s() As String = Args(1) \'\'工具条中要添加的控件,如加入分隔条,则用"分隔条"

Dim ToolStrip1 As New System.Windows.Forms.ToolStrip \'定义一个新的工具条
\'\'生成不重复的工具条名
Dim i As Integer
Dim nm As String
Do
i = i + 1
If ctr.Form.ExistControl("工具条" & i) = False Then
nm = "工具条" & i
Exit Do
End If
Loop
\'\'在容器中添加工具条
ToolStrip1.name = nm
ToolStrip1.Dock = System.Windows.Forms.DockStyle.Fill \'\'铺满
ctr.baseControl.Controls.add(ToolStrip1)
\'\'在工具条中添加控件
If s.Length > 0 Then
For Each str As String In s
If str = "分隔条" Then
Dim ToolStripSeparator1 As New System.Windows.Forms.ToolStripSeparator \'\'定义分隔条
ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {ToolStripSeparator1}) \'\'加入分隔条
Else
If ctr.Form.ExistControl(str) = True Then \'\'如果存在此控件则添加依次添加工具条中
Dim tl As object = ctr.Form.Controls(str).BaseControl \'要加入工具条的控件
Dim p As New System.Windows.Forms.Panel \'初始化容器
p.Size = tl.Size
tl.top = 0 \'定义控件位置
tl.left = 0
tl.Dock = System.Windows.Forms.DockStyle.None
tl.Anchor = System.Windows.Forms.AnchorStyles.Left \'用来居左
p.Controls.add(tl) \'控件加入容器
Dim dateTimePickerHost As new System.Windows.Forms.ToolStripControlHost(p)
toolStrip1.Items.Add(dateTimePickerHost) \'容器加入工具条
End If
End If
Next
End If
[此贴子已经被作者于2016/6/18 11:02:44编辑过]

--  作者:Hyphen
--  发布时间:2016/6/18 10:52:00
--  
重新上传您的项目或者代码到这里
--  作者:pcxjxjhkw
--  发布时间:2016/6/18 11:45:00
--  

问题已解决,

一新问题:

 

如何在一工具条中加入两排按钮.


--  作者:Hyphen
--  发布时间:2016/6/18 14:35:00
--  
ToolStrip1.LayoutStyle = 3,只有宽度不够的时候才会显示排到下面