如何在PropertyGrid上调用"MouseClick"事件 [英] How to invoke the 'MouseClick' event on PropertyGrid

查看:114
本文介绍了如何在PropertyGrid上调用"MouseClick"事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

================================================ ====
(改进的问题)

这是一个改进的问题,请首先查看原始问题",然后在"Answer1"中查找以下文本,谢谢OriginalGriff提供的建议尝试以下几行:

===================================================
(Improved question)

This is improved question, please first see the ''original question'', and then the following text in ''Answer1'', thanks OriginalGriff provide the suggestion to try the following lines :

foreach (Control c in propertyGrid1.Controls)
{   c.MouseClick += new MouseEventHandler
                   (MyMouseClickEventHandlerWhatEverItIsCalledInYourCode)
};



但是当我进行验证时,它显示无法生成"propertyGrid1.Controls"!但是,我看到有可以选择ControlAdded和ControlRemoved的事件,为什么它不能有"propertyGrid1.Controls"!任何人都可以帮助显示根本原因吗?


================================================== ==
(原始问题)

我编写了一个Window窗体应用程序,并将PropertyGrid放在窗体上以及PropertyGrid atrribute表中:

1.我将对象分配给SelectedObject属性.
1.启用"MouseClick"事件.
2.在"MouseClick"事件中写一行"int i = 0"(仅用于调试).
3.运行它,它工作正常.

但是,当我单击PropertyGrid时,将不会调用"MouseClick"事件!
但是,当我将事件设置更改为"SelectedGridItemChanged",然后单击different
PropertyGid上的grititem,然后可以调用"SelectedGridItemChanged"事件!

问题:
1.如何让"MouseClick"事件被调用?
我的目的是检测是否单击了任何网格,然后检查网格是否为
我想进行高级处理的那个.
2.实际上,我想让用户编辑一些具有文本字符串数组的网格项目.
我在CodePage中搜索了一些文章,其中提到了达到
的方式 它,但是一切似乎都太复杂了,我想那里应该有一种简单的方法来实现
我的要求,任何人都可以向我展示简单详细的示例以供参考吗?

注意:
1."SelectedGridItemChanged"事件无法满足我的要求,因为我不会执行
只是在更改项目时进行专用的高级处理,而当用户
时,我会这样做 右键单击鼠标(以编辑单击的网格项目的文本)
2.该系统具有内置文本查看功能,例如在移动
时可以查看网格 将鼠标放在具有字符串数组类型的griditem的值行上,系统将
自动显示整个文本窗口供用户查看.但是,我想这不是
足以让用户进行编辑,因此我要求让用户单击griditem,然后
然后可以显示一个多行文本框供用户编辑.



But when I do verification, it shows can not generate "propertyGrid1.Controls" ! However, I see there are events of ControlAdded and ControlRemoved can be selected, why it can not have "propertyGrid1.Controls" !? Can any one helps to show the root cause ?


====================================================
(Original question)

I write a Window form application, and place a PropertyGrid on form, and in PropertyGrid atrribute table :

1. I assign object to the SelectedObject attribute.
1. Enable the ''MouseClick'' event on.
2. Write one line ''int i=0'' in the ''MouseClick'' event (for debug only).
3. Run it, and it works fine.

However, when I click the PropertyGrid, the ''MouseClick'' event will not be invoked !
But, when I change the event setting to be ''SelectedGridItemChanged'', and click differnt
grititem on PropertyGid, it then can invoke the ''SelectedGridItemChanged'' event !

Question :
1. How can I let the ''MouseClick'' event be invoked ?
My purpose is to detect if any griditem is clicked, and then check if the griditem is
the one I would like to do advanced process.
2. Actually, I would like for user to edit some griditems, which has string array of text.
I''ve searched some articles in CodePage, which have mentioned about the way to reach
it, but all seems be so complicated, I surpose there should have simple way to reach
my request, can any one show the simple and detailed sample to me for reference ?

note :
1. The ''SelectedGridItemChanged'' event can not meet my request, since I would not do the
dedicated advanced process when item is just changed, and, I would do it when user
right click mouse (to edit the text of the clicked griditem)
2. The system has built-in function of text viewing for griditem, such as when moving
mouse on the value row of griditem which has type of string array, the system will
automatically show the whole text window for user to view. But, I surpose it''s not
enough for user to do editing, so I request to let user to click the griditem, and
then can show a muliple line textbox for user to edit.

推荐答案

PropertyGrid包含完全填充控件工作区域的子控件:结果,整个控件MouseClick事件永远不会触发.
Click事件有时(但并非总是如此,取决于您单击控件的哪一部分).

如果您确实需要MouseClick事件,那么您将必须递归地浏览PropertyGrid实例控件列表,并在其中插入MouseClick事件.

"====================================
感谢您的回复.
关于以递归方式遍历PropertyGrid实例控件列表并连接到那里的MouseClick事件",您能否写一些行(或描述更多单词),以便我可以看到它的外观?
=========================================


您的表单:
The PropertyGrid contains child controls which completely fill the controls working area: As a result, the overall control MouseClick event is never fired.
The Click event is, sometimes (but not always, it depends on what part of the control you click on).

If you really need the MouseClick event, then you will have to follow through the PropertyGrid instance Controls list recursively and hook into the MouseClick events there.

"=======================================
Thanks of your response.
Regarding ''to follow through the PropertyGrid instance Controls list recursively and hook into the MouseClick events there.'', could you write some lines (or describe more words), so that I can image what it look like ?
==========================================="


In your form:
foreach (Control c in propertyGrid1.Controls)
   {
   c.MouseClick += new MouseEventHandler(MyMouseClickEventHandlerWhatEverItIsCalledInYourCode);
   }

您可能需要遍历子控件列表,但这很容易实现.

You may need to recurse through sub control lists, but that is a simple matter to implement.


这篇关于如何在PropertyGrid上调用"MouseClick"事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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