方法2中如何控制left top呢? 比如 如何控制一排按照我设计的个数排 ? 按钮个数是不确定的 比如我想一排2个 这个要怎么来写
我找到之前一个案列的代码是这样的 但是套过来用 达不到效果 按钮会重叠在一起 或者互相覆盖了
Dim tab1 As WinForm.TabControl
tab1 = e.Form.CreateControl("tab1", ControlTypeEnum.TabControl)
e.Form.Controls("Panel1").addcontrol(tab1)
tab1.Dock = System.Windows.Forms.DockStyle.fill
e.Form.Controls("tab1").basecontrol.ItemSize=new Size(60,55)
tab1.Multiline=True
Dim fnt As new Font("微软雅黑",16,FontStyle.Regular)
tab1.Font=fnt
Dim x As Integer
Dim str As String
Dim pan As WinForm.Panel
For x =65 To 90
str=chr(x)
tab1.TabPages.Add(str,str)
pan = e.Form.CreateControl("pan" & chr(x), ControlTypeEnum.panel)
pan.Dock = System.Windows.Forms.DockStyle.fill
pan.AutoScroll=True
pan.BackColor = color.Silver
e.Form.Controls("tab1").basecontrol.tabpages(str).addcontrol(pan)
Next
Dim dt As DataTable
Dim sqltxt As String="S elect 药材编码,名称 from {产品资料} order by 名称"
Dim sql As String="sel ect count(*) as 总行数 from{产品资料} where 药材编码 is not null"
Dim c md As ne w SQL Command
cm d.C
cm d.CommandText=sql
dt=cm d.ExecuteReader
If dt.DataRows(0)("总行数")=DataTables("产品资料").datarows.count Then
dt=DataTables("产品资料")
Else
Dim cmd1 As new SQLCommand
cmd1.C
cmd1.CommandText=sqltxt
dt=cmd1.ExecuteReader
End If
Dim lst As List(of DataRow)
lst=dt.Select("","名称")
Dim btn As WinForm.button
Dim i As Integer =0
For x =65 To 90
i=0
''For Each dr As DataRow In dt.DataRows
For Each dr As DataRow In lst
If left(GetPY(dr("名称"), True),1)=chr(x) Then
btn = e.Form.CreateControl(dr("药材编码"), ControlTypeEnum.button)
btn.width=250
btn.height=70
btn.BackColor=Color.white
btn.VisualStyle = VisualStyleEnum.office2007blue
btn.Text = dr("名称")
btn.Left = 35+(i Mod 4)*280
btn.Top = 35+(i\4)*95
btn.Image = GetImage("noselect.png")
btn.TextImageRelation = TextImageRelation.ImageBeforeText
btn.basecontrol.tag=0
e.Form.Controls("pan" & left(GetPY(dr("名称"), True),1)).AddControl(btn)
i=i+1
End If
Next
Next
e.Form.baseform.WindowState=2
核心代码是
btn.Left = 35+(i Mod 4)*280
btn.Top = 35+(i mod 4)*95
但是我套过来用 发现不行 比如有4个按钮 只能显示2个 互相重叠在一起了