在ListBox上按Enter键应调用DoubleClick [英] Pressing Enter on ListBox should invoke DoubleClick

查看:96
本文介绍了在ListBox上按Enter键应调用DoubleClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要运行相同的功能,无论你按Enter键还是双击

点击列表框。每次将两个处理程序写入

似乎非常冗长,即使它们都调用相同的函数,或者

一个调用另一个。


是否有选择列表框选择的事件是否由所有标准GUI方式自动调用?b $ b? C''mon,

这是C#,我们不应该编程GUI。有这样一个事件有

,否则大多数C#GUI代码都会破坏用户界面。


如果没有感觉事件,我可以做任何

ListBox'的Enter按下的通用处理程序,它调用列表框的DoubeClick事件。

如何调用这样的事件?我似乎无法调用

Control.RaiseMouseEvent强制DoubleClick根据需要调用。


我很遗憾想知道为什么这个基本的GUI功能是所以

很难用C#。


Zytan

I want the same function to be run whether you press Enter or double
click the listbox. It seems really verbose to write both handlers to
both events everytime, even if they both call the same function, or
one calls the other.

Isn''t there an event for ''ListBox selection selected'' that is
automatically called by ALL the standard GUI ways of doing it? C''mon,
this is C#, we aren''t supposed to be programming the GUI. There has
to be such an event, or else most C# GUI code has broken UI.

If there''s no sense event, I could make a generic handler for any
ListBox''s Enter press, which calls the listbox''s DoubeClick event.
How can I invoke such an event? I seem unable to call
Control.RaiseMouseEvent to force DoubleClick to be invoke as needed.

I''m a little lost wondering why this basic GUI functionality is so
difficult in C#.

Zytan

推荐答案

您可以扩展列表框并调用您自己的活动来代替您感兴趣的

活动。


Jeremy Shovan

Zytan < zy ********** @ gmail.comwrote in message

news:11 ******************** **@n59g2000hsh.googlegr oups.com ...
You could extend the list box and invoke your own event in place of the the
events you are interested in.

Jeremy Shovan
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...

>我想要运行相同的功能,无论你按Enter还是双击

单击列表框。每次将两个处理程序写入

似乎非常冗长,即使它们都调用相同的函数,或者

一个调用另一个。


是否有选择列表框选择的事件是否由所有标准GUI方式自动调用?b $ b? C''mon,

这是C#,我们不应该编程GUI。有这样一个事件有

,否则大多数C#GUI代码都会破坏用户界面。


如果没有感觉事件,我可以做任何

ListBox'的Enter按下的通用处理程序,它调用列表框的DoubeClick事件。

如何调用这样的事件?我似乎无法调用

Control.RaiseMouseEvent强制DoubleClick根据需要调用。


我很遗憾想知道为什么这个基本的GUI功能是所以

很难用C#。


Zytan
>I want the same function to be run whether you press Enter or double
click the listbox. It seems really verbose to write both handlers to
both events everytime, even if they both call the same function, or
one calls the other.

Isn''t there an event for ''ListBox selection selected'' that is
automatically called by ALL the standard GUI ways of doing it? C''mon,
this is C#, we aren''t supposed to be programming the GUI. There has
to be such an event, or else most C# GUI code has broken UI.

If there''s no sense event, I could make a generic handler for any
ListBox''s Enter press, which calls the listbox''s DoubeClick event.
How can I invoke such an event? I seem unable to call
Control.RaiseMouseEvent to force DoubleClick to be invoke as needed.

I''m a little lost wondering why this basic GUI functionality is so
difficult in C#.

Zytan


你可以扩展名单框并创建自己的代表以获得您正在寻找的

功能。


Jeremy Shovan

" Zytan" < zy ********** @ gmail.comwrote in message

news:11 ******************** **@n59g2000hsh.googlegr oups.com ...
You could extend the list box and create your own delegate to get the
functionality you are looking for.

Jeremy Shovan
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...

>我想要运行相同的功能,无论你按Enter还是双击

单击列表框。每次将两个处理程序写入

似乎非常冗长,即使它们都调用相同的函数,或者

一个调用另一个。


是否有选择列表框选择的事件是否由所有标准GUI方式自动调用?b $ b? C''mon,

这是C#,我们不应该编程GUI。有这样一个事件有

,否则大多数C#GUI代码都会破坏用户界面。


如果没有感觉事件,我可以做任何

ListBox'的Enter按下的通用处理程序,它调用列表框的DoubeClick事件。

如何调用这样的事件?我似乎无法调用

Control.RaiseMouseEvent强制DoubleClick根据需要调用。


我很遗憾想知道为什么这个基本的GUI功能是所以

很难用C#。


Zytan
>I want the same function to be run whether you press Enter or double
click the listbox. It seems really verbose to write both handlers to
both events everytime, even if they both call the same function, or
one calls the other.

Isn''t there an event for ''ListBox selection selected'' that is
automatically called by ALL the standard GUI ways of doing it? C''mon,
this is C#, we aren''t supposed to be programming the GUI. There has
to be such an event, or else most C# GUI code has broken UI.

If there''s no sense event, I could make a generic handler for any
ListBox''s Enter press, which calls the listbox''s DoubeClick event.
How can I invoke such an event? I seem unable to call
Control.RaiseMouseEvent to force DoubleClick to be invoke as needed.

I''m a little lost wondering why this basic GUI functionality is so
difficult in C#.

Zytan


Zytan,

好​​笑,我不记得在C#规范的哪个地方它说我们不应该是b $ b编码用户界面...

这样做比较好,说实话,大多数用户界面都没有因此而损坏。


你刚才有连接你的班级,让两个事件处理程序将

路由到相同的代码。这并不难。


如果您有许多需要此功能的列表框,那么

只需扩展ListBox类并创建一个新的当你发生这些事件时,你可以挂钩的事件



-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Zytan" < zy ********** @ gmail.comwrote in message

news:11 ******************** **@n59g2000hsh.googlegr oups.com ...
Zytan,

Funny, I don''t recall where in the C# spec it says we shouldn''t be
coding UI...

It is better this way, to be honest, and most UIs out there are not
broken because of this.

You just have to wire up your class to have both event handlers to route
to the same code. It''s not that hard.

If you have a number of listboxes that require this functionality, then
just extend the ListBox class and create a new event which you can hook up
to which fires when either of those events takes place.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...

>我想要运行相同的功能,无论你按Enter还是双击

单击列表框。每次将两个处理程序写入

似乎非常冗长,即使它们都调用相同的函数,或者

一个调用另一个。


是否有选择列表框选择的事件是否由所有标准GUI方式自动调用?b $ b? C''mon,

这是C#,我们不应该编程GUI。有这样一个事件有

,否则大多数C#GUI代码都会破坏用户界面。


如果没有感觉事件,我可以做任何

ListBox'的Enter按下的通用处理程序,它调用列表框的DoubeClick事件。

如何调用这样的事件?我似乎无法调用

Control.RaiseMouseEvent强制DoubleClick根据需要调用。


我很遗憾想知道为什么这个基本的GUI功能是所以

很难用C#。


Zytan
>I want the same function to be run whether you press Enter or double
click the listbox. It seems really verbose to write both handlers to
both events everytime, even if they both call the same function, or
one calls the other.

Isn''t there an event for ''ListBox selection selected'' that is
automatically called by ALL the standard GUI ways of doing it? C''mon,
this is C#, we aren''t supposed to be programming the GUI. There has
to be such an event, or else most C# GUI code has broken UI.

If there''s no sense event, I could make a generic handler for any
ListBox''s Enter press, which calls the listbox''s DoubeClick event.
How can I invoke such an event? I seem unable to call
Control.RaiseMouseEvent to force DoubleClick to be invoke as needed.

I''m a little lost wondering why this basic GUI functionality is so
difficult in C#.

Zytan



这篇关于在ListBox上按Enter键应调用DoubleClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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