简体   繁体   English

动态生成链接菜单vb.net

[英]Generate dynamically a menu of links vb.net

In my program I need to display the names of all opened workbooks of Excel in the Task Bar and their corresponding sheets in a form so that the user can select one workbook with one sheet to import it's data. 在我的程序中,我需要在任务栏中以表格形式显示所有打开的Excel工作簿的名称及其对应的工作表,以便用户可以选择一个工作表和一个工作表来导入其数据。 Knowing that I have the list of full path's stored in string, still the problem is that I don't know how to generate like a menu of checkbox's that contains the path of the workbooks and sheets so that when the user selects one of the checkbox's, the full path is to be passed to the import function; 知道我已将完整路径的列表存储在字符串中,但问题仍然是我不知道如何生成像复选框的菜单一样的菜单,其中包含工作簿和工作表的路径,以便当用户选择复选框的菜单时,完整路径将传递给import函数; any ideas; 有任何想法吗; Help is very appreciated. 非常感谢您的帮助。

remark:FNAME contains the full path of excel workbooks 备注:FNAME包含excel工作簿的完整路径

 Dim offset = 60
 Dim offset1 = 50
 Dim f As Integer = 0
 For Each cur In FName
    Dim checkBox As New System.Windows.Forms.CheckBox()
    Me.Controls.Add(checkBox)
    checkBox.Location = New System.Drawing.Point(offset, offset1)
    checkBox.Text = cur
    checkBox.Checked = True
    checkBox.Name = "CKB" & f
    checkBox.Size = New Size(1000, 20)
    'offset = offset + 100
    offset1 += 25
    f += 1
Next

You could assign the CheckBox's Tag property to the file path, then in it's events it will be visible on Sender.Tag . 您可以将CheckBox的Tag属性分配给文件路径,然后在事件中它将在Sender.TagSender.Tag Check this out. 检查这个出来。

To set events on the controls you should use AddHandler. 要在控件上设置事件,应使用AddHandler。 See this for more info! 为更多信息!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM