处理事件 [英] working with event

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

问题描述

大家好,

我在表单上添加了新的简单按钮

Hi everyone,

I add new simple button on my form

ArrayList  a=new ArrayList ();
  int counter;

 void x()
       {
            a.Add(new SimpleButton());
           propertyGridControl1.SelectedObject = ((SimpleButton)a[counter]);
           ((SimpleButton )a[counter]).Height =10;
           ((SimpleButton)a[counter ]).Width = 10;
           ((SimpleButton)a[counter]).Text = "mo";
           ((SimpleButton)a[counter]).Parent = pictureEdit1;
           ((SimpleButton)a[counter]).Location = new Point(10, 10);
             counter = +1;
       }


好的,我想这样,当我点击[计数器]时,我会显示该消息框,并能够通过鼠标单击将该a [计数器]移动到任何位置. 好的\
感谢您的帮助


Ok I want so when I press click on a[counter] I show the message box and have ability to move this a[counter] to any place with mouse click move on picture Parent
ok \
thanks for any help

推荐答案

我不确定您要实现的目标,但是查看您的代码片段,我不确定您不是.

您所做的不会在表单中添加按钮.它将一个SimpleButton(我假设是您定义的一个类)添加到ArrayList,而不是您的窗体.
然后将计数器设置为1.

要在运行时向表单添加按钮:
I''m not exactly sure what you are trying to achieve, but lookat your code fragment, I''m not sure you are either.

What you have done does not add a button to your form. It adds a SimpleButton (which I assume is a class you have defined) to an ArrayList, but not to your form.
It then sets a counter to one.

To add a button to your form at run time:
Button myButton = new Button();
myButton.Height =10;
myButton.Width = 10;
myButton.Text = "mo";
myButton.Location = new Point(10, 10); 
Controls.Add(myButton);


我假设您也想增加计数.如果是这样,请使用以下形式之一:


I assume that you also wanted to increment the count. If so then use one of these forms:

counter += 1;


counter = counter + 1;


counter++;


我也不会将父对象"用于控件,除非我真的必须-它使控件需要知道包含它的内容,而不是对象知道它包含的内容.

至于其余的将鼠标移到图片任何地方,请在图片父上移动",请尝试提供更多有关您要实现的信息.


I would also not refer to "Parent" for a control, unless I really had to - it makes the control need to know about what contains it, rather than an object knowing about what it contains.

As for the rest "move this a[counter ] to any place with mouse click move on picture Parent" please try to give more info on what you are trying to achieve.


这里是一个实现运动的方式部分:
用户驱动的应用程序 [ DevExpress属性网格控件 [使用功能强大的DesignSurface(扩展)类具有出色的DesignTime体验 [用于Windows窗体的DevExpress布局管理器控件 [
Here is one way to achieve the movement part:
User-driven applications[^].

When you have read and understood the article - the rest shouldn''t be much of a problem.

I guess you are using DevExpress Property Grid Control[^] so this article should be of interest: Have a Great DesignTime Experience with a Powerful DesignSurface (Extended) Class[^] - not on the DevExpress components, but shows how something similar to the layout controls (the customize part) could be done using DesignSurface.

You could also use the DevExpress Layout Manager Controls for Windows Forms[^] - most, if not all, of what you need is included with the examples :)

Basically a good collection of links - and with a bit of reading you should be able to make a wonderful UI.

Good luck!

Regards
Espen Harlinn


这篇关于处理事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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