C#Winforms - 为什么不在IDE中显示控件事件? [英] C# Winforms - why not show a controls events in the IDE?

查看:55
本文介绍了C#Winforms - 为什么不在IDE中显示控件事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在VB.Net中,当您双击一个控件时,您会在组合框中看到该控件的所有可用的
事件。点击一下,

界面代码就在那里等着您输入实现。


为什么这不会出现在C#中?我必须自己编写函数头

?为什么看起来C#不会比VB.Net更低效率?b $ b?这是在2005年修复过吗?


In VB.Net, when you double click a control you see all available
events of that control in a combo box. Click on one, and the
interface code is right there waiting for you to type implementation.

Why does this not occur in C#? I have to write the function header
myself? Why does it seem C# goes out of its way to be less productive
than VB.Net? Has this been fixed in 2005?

推荐答案

" Greg Muncien"写了...
"Greg Muncien" wrote...

在VB.Net中,当你双击一个控件时,你会在组合框中看到该控件的所有可用事件。单击一个,
接口代码就在那里,等待您输入实现。

为什么在C#中不会出现这种情况?我必须自己编写函数头吗?为什么C#似乎不会比VB.Net更低效?这是在2005年修复过吗?

In VB.Net, when you double click a control you see all available
events of that control in a combo box. Click on one, and the
interface code is right there waiting for you to type implementation.

Why does this not occur in C#? I have to write the function header
myself? Why does it seem C# goes out of its way to be less productive
than VB.Net? Has this been fixed in 2005?




我不确定你使用的是什么IDE,但是在我的Visual C#.NET中我发现它甚至是

更容易...


对于大多数控件来说,只需双击

控件本身就足够了,就像那时一样将生成最常见事件的代码

(例如按钮的Click事件等)。


如果我想使用其他事件,我只是标记控件,然后有一个

属性视图(在我的版本右下角),我可以选择查看

属性(kategorized或alphabetic)或者事件。


如果我选择查看事件,我只需双击它就可以了,

那里有我需要的所有代码。


恕我直言,C#编辑器在这个意义上比相应的

VB编辑器更有效率,正如你所描述的那样......


// Bjorn A



I''m not sure what IDE you''re using, but in my Visual C#.NET I find it even
easier...

For the most controls it''s sufficient enough to simply double click the
control itself, as then the code for the most common event will be generated
(e.g. the Click-event for a Button, etc).

If I want to use another event, I simply mark the control, then there''s a
property view (bottom right in my version), where I can select to view
properties (kategorized or alphabetic) or events.

If I choose to look at the events, I simply double click on it and voilà,
there''s all the code I need.

IMHO the C#-editor is in that sense more productive than the corresponding
VB-editor, as you have described it...

// Bjorn A


寻求和你们大厅找到。 :-)


在属性窗口中,工具栏上有一个闪电图标

位于属性网格的顶部。点击它,它切换到

事件视图。双击每个事件旁边会写入标题,

将事件处理程序连接到控件的事件。或者,如果你已经用
编写了一个方法,你可以点击事件旁边的,然后从出现的组合框中选择

方法。

这已经在VS2003中可用。

Seek and ye shall find. :-)

In the properties window there is a lightning bolt icon on the toolbar
at the top of the property grid. Click on that and it switches to the
events view. Double-clicking beside each event writes the header and
connects the event handler to the control''s event. Or, if you already
have a method coded, you can click beside the event and choose the
method from the combo box that appears.

This is already available in VS2003.


2005年11月9日星期三19:08:25 +0100,Bjorn Abelli

< bj ********** @ DoNotSpam.hotmail.com>写道:
On Wed, 9 Nov 2005 19:08:25 +0100, "Bjorn Abelli"
<bj**********@DoNotSpam.hotmail.com> wrote:
" Greg Muncien"写了...
"Greg Muncien" wrote...

在VB.Net中,当你双击一个控件时,你会在组合框中看到该控件的所有可用事件。单击一个,
接口代码就在那里,等待您输入实现。

为什么在C#中不会出现这种情况?我必须自己编写函数头吗?为什么C#似乎不会比VB.Net更低效?这是在2005年修复过的吗?

In VB.Net, when you double click a control you see all available
events of that control in a combo box. Click on one, and the
interface code is right there waiting for you to type implementation.

Why does this not occur in C#? I have to write the function header
myself? Why does it seem C# goes out of its way to be less productive
than VB.Net? Has this been fixed in 2005?



我不确定你使用的是什么IDE,但在我的Visual C#.NET中我发现它甚至更容易。 ..

对于大多数控件,它足以简单地双击
控件本身,因为那时将生成最常见事件的代码
(例如,按钮的Click事件等。

如果我想使用另一个事件,我只需标记控件,然后有一个
属性视图(在我的版本右下角) ),我可以选择查看属性(分类或字母)或事件。

如果我选择查看事件,我只需双击它就可以了,我需要的所有代码。

恕我直言,C#-editor在这个意义上比相应的VB编辑器更有效率,正如你所描述的那样......

// Bjorn A



I''m not sure what IDE you''re using, but in my Visual C#.NET I find it even
easier...

For the most controls it''s sufficient enough to simply double click the
control itself, as then the code for the most common event will be generated
(e.g. the Click-event for a Button, etc).

If I want to use another event, I simply mark the control, then there''s a
property view (bottom right in my version), where I can select to view
properties (kategorized or alphabetic) or events.

If I choose to look at the events, I simply double click on it and voilà,
there''s all the code I need.

IMHO the C#-editor is in that sense more productive than the corresponding
VB-editor, as you have described it...

// Bjorn A




好​​的,第二眼我承认它可能会归结为苹果和橘子

类型的比较。关于C#真的很狡猾的是,如果对于

示例你只需要创建一个表单,然后将列表框拖到它上面,然后在属性/事件窗口中查看事件

,并为DoubleClick事件选择

下拉列表,任何可能已经连线的事件(即SelectedIndexChanged事件)都显示在
$中b $ b组合。对我来说,将DoubleClick

事件处理程序连接到DoubleClick事件(并生成适当的代码)

比建议SelectedIndexChanged事件更合乎逻辑。


它在VB.Net中的工作方式几乎就是在DotNet出现之前多年在VB(以及

Delphi)中工作的方式,这可能就是为什么它对我来说似乎更直观..也许它在C#中的工作方式更像是在Java或C ++环境下的b $ b?我不知道,但我想这就是微软推销VB.Net作为提高生产力的解决方案的理由,以及c#作为解决方案....好吧......制作

java人们更容易转换到DotNet。



Ok, on second glance I admit it may come down to an apples and oranges
type of comparison. Whats really goofy about C# is that if for
example you just create a form, then drag a listbox to it, then look
in the properties/events window for the events, and choose the
dropdown for the DoubleClick event, any events that might have already
been wired up (i.e. the SelectedIndexChanged event) shows up in the
combo. To me it seems much more logical to wire up the DoubleClick
event handler to the DoubleClick event (and generate appropriate code)
than to suggest the SelectedIndexChanged event.

The way it works in VB.Net is pretty much the way it worked in VB (and
Delphi) for many years before DotNet came along, which may be why it
seems more intuitive to me.. Perhaps the way it works in C# is more
like Java or C++ environments? I don''t know, but I guess thats one of
the rationales behind Microsoft pitching VB.Net as the solution for
higher productivity, and c# as the solution for.... well... to make
it easier for java folks to transition over to DotNet.


这篇关于C#Winforms - 为什么不在IDE中显示控件事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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