带有图片数组的上下文菜单 [英] contextmenu with picturearray

查看:88
本文介绍了带有图片数组的上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dim array as new list(of picturebox)
dim pic as new picturebox
me.controls.add(pic)
array.add(pic)



我使用此代码在运行时创建图片框.现在,我想在pictureboxes数组中添加contextmenu.因此,我采用delete(index-0),create(index-1)&创建有5个子菜单.因此请使用此代码.



i used this code to create picturebox at runtime .now i want to add contextmenu in array of pictureboxes.so i take contextmenustrip in the form with delete(index-0),create(index-1) & create has 5 sub menu.so iused this code.

pic.ContextMenuStrip = ContextMenuStrip1



然后我在me.remove.controls(pic)的"Deletecontextmenustrip_click"中键入代码以删除图片框,但出现错误.
我用contextmenustrip&尝试了addhandler被称为过程,但也无法正常工作.



then i typed code to remove picturebox in "Deletecontextmenustrip_click", me.remove.controls(pic) but i got error.
i tried addhandler with contextmenustrip & called procedure but not working too.


AddHandler pic.ContextMenuStrip.Items(0).Click, AddressOf DeleteToolStripMenuItem_Click



在该过程中,我使用了me.controls.remove(sender)



In the procedure i used me.controls.remove(sender)

推荐答案

您绝对不要在菜单栏中使用PictureBox.类System.Windows.Forms.MenuStrip使用完全不同的方法来显示菜单项的图像.您应该改用类型为System.Windows.Forms.ImageList的属性ImageList.一切都在这里说明:
http://msdn.microsoft.com/en-us/library/system. windows.forms.menustrip.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstrip.imagelist.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.forms.imagelist.aspx [ ^ ].

—SA
You should nover use PictureBox with a menu strip. The class System.Windows.Forms.MenuStrip uses quite different approach to present images for menu items. You should use the property ImageList of the type System.Windows.Forms.ImageList instead. Everything is explained here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.menustrip.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstrip.imagelist.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.aspx[^].

—SA


这篇关于带有图片数组的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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