如何使以编程方式创建的列表项可点击? C# [英] how to make programatically created list items clickable? C#

查看:94
本文介绍了如何使以编程方式创建的列表项可点击? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小程序,我在其中创建收藏夹列表并将其以编程方式添加到工具栏菜单中.
有什么方法可以使项目可点击,以便我实际上可以点击链接

我通过
添加了它们

i have a small program where i create a list of favorites and add them to a toolstrip menu programatically
is there any way to make the items clickable so i can actually follow the links

i added them through

ToolStripMenuItem item = new ToolStripMenuItem(favourite.URL);
                linksToolStripMenuItem.DropDownItems.Add(item);



我该使用哪个属性来使其实际可点击?
我在想什么
使用点击事件处理程序,但我自己似乎无法弄清>.<< br mode ="hold"/>
在此先感谢



which property do i use to actually make them clickable?
i was thinking something in the lines of
using a click eventhandler but can''t seem to figure this one out by myself >.<<br mode="hold" />
thanks in advance

推荐答案

MenuItem是可单击的",您只需要在Menu控件上处理该事件.
MenuItems are "clickable", you just need to handle the event on the Menu control.


添加该代码之后的代码:

Add this after that code:

item.Click += 



(然后几次点击标签,让intellisiense为您填充它.到那时,您将能够将代码放入所提供的方法中,并且菜单项将是可单击的".



(and then hit tab a few times and let intellisiense fill it in for you. At that point, you''ll be able to put code into the method provided and the menu item will be "clickable".


根据MSDN文档,ToolStripMenuItem类型有一个Click事件.因此,在代码中要做的就是将事件处理程序附加到该事件处理程序.
干杯!

--MRB
According to MSDN documentation the ToolStripMenuItem type has a Click event. So all you have to do in your code is to attach an event handler to it.

Cheers!

--MRB


这篇关于如何使以编程方式创建的列表项可点击? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆