如何找到ContextMenuStrip的父控件

如何找到ContextMenuStrip的父控件

本文介绍了如何找到ContextMenuStrip的父控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的问题是我有一个contextmenustrip,它由表单上的多个按钮使用,并且contextmenustrip具有contextmenustripitems,它们调用自定义按钮外观的方法,例如字体,前景色和背景色.

问题是我试图获取已调用contextmenustrip的按钮.这样做的原因是,我可以通过向当前按钮提供将进行这些更改的方法作为参数,然后将颜色或新字体应用于已打开contextmenustrip的按钮.

我真的不知道该怎么做,因此不胜感激:)

Hi all,

My problem is that I have a contextmenustrip that is used by multiple buttons on a form and the contextmenustrip has contextmenustripitems, that call methods that customize the look of a button, for instance the font, fore and back colour.

The problem being is that I am trying to get the button that the contextmenustrip has been called on. The reason for this is so that I can then apply the colour or new font to the button that has had the contextmenustrip opened on, by supplying the current button the method that will make these changes, as an argument.

I don''t really know how I would go about doing this so any help is much appreciated :)

推荐答案

Private Sub ContextMenuStrip1_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening

    Debug.WriteLine(ContextMenuStrip1.SourceControl.ToString)

End Sub


这篇关于如何找到ContextMenuStrip的父控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 20:57