我有一个棘手的问题,我无法弄清楚。
我在该标签页上有一个标签页存在一排水平的按钮,一排有5个按钮。最终用户可以创建X个新按钮。我想要的但是无法弄清楚我怎样才能制作多达5个按钮的水平行,而不是更多。如果该行超过了5个按钮的限制,那么应该在下面开始一个新行?
我试图捕捉各种尺寸,例如标签页宽度除以(按钮+在空格之间)宽度等。
使用vb.net是否有一种简单的方法可以做到这一点?
修改
Public Class create_allined_rows
Private Sub create_allined_rows_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim BTNCOUNT As Integer = Me.TabPage1.Controls.Count
MsgBox("There are " & BTNCOUNT & " buttons currently on tabpage1.")
Dim numofrows As Integer = Math.Ceiling(BTNCOUNT / 5)
MsgBox("there should be " & numofrows & " on this form...")
MsgBox("button 16 should be located in the " & numofrows & "st column...")
MsgBox("button 17 should be located in the " & numofrows & "nd column...")
MsgBox("thus button 16 dimentional location should be " & " ?x " & (numofrows * 100 + numofrows * 5) & "pix .")
MsgBox("thus button 17 dimentional location should be " & " ?x " & (numofrows * 100 + numofrows * 5) & "pix .")
End Sub
End Class
答案 0 :(得分:0)
这很容易!看,你没有提供你的代码,我不能说你面临的具体困难是什么,你如何制作新的按钮!?我不知道。您可以添加在后台运行的文本框。每次创建一个新按钮时添加一个数字。
然后使用MOD操作符完成您的工作。
Private Sub Form1_Load () Handles Form1.Load
Textbox1.Visible = False
'Or you can write here Textbox1.Hide
End Sub
Private Sub AddButton_Click () Handles AddButton.Click
Textbox1.Text = Val(Textbox1.Text) + 1
If Val(Textbox1.Text) MOD 5 = 0 then
'Code for moving to next line
Else
'The normal code you have written
End If
End Sub
希望它完美无缺!