Visual Studio C#UI快捷方式 [英] Visual Studio C# UI shortcuts

查看:82
本文介绍了Visual Studio C#UI快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主要是一名VB开发人员,但现在正在用C#做一个项目。在VB中,无论您使用的是Windows还是Web应用程序,每个代码隐藏页面的左侧下拉列表都会显示表单/页面的名称以及该页面上的所有控件。您可以选择任何项目,并在右侧下拉菜单中,它会显示该控件的所有可用事件;选择一对,如果尚未定义,则自动为该代码块添加模板,或者如果已经定义,则导航到该代码块。我已经看到有一种方法可以为控件事件添加这样的代码块(通过属性窗口选择),但似乎没有办法为表单级事件执行此操作。我错过了什么吗? C#的左手下拉是否有任何目的?除右手下拉导航之外的任何其他目的吗?



编辑:必须是C# - 只有开发人员回复,因为这不会打扰任何人。我在办公室问了一下,也没有人知道。有人说它可能是一个错误,但很难相信只要我知道它就会离开MS(我不是全新的C#,从来没有做过任何大事或从头开始)。是的,正如我上面所说,我看到你可以使用Properties窗口控制事件和Windows窗体事件。但为什么不选择页面活动?再说一次......左下拉的目的是什么?这可能只会困扰那些使用VB的人,那些下拉列表是功能性和有用的快捷方式。

I've been primarily a VB developer, but now doing a project in C#. In VB, whether you're doing a Windows or a web app, the left-hand dropdown of every code-behind page shows the name of the form/page and all the controls on that page. You can select any item, and them in the right-hand dropdown, it'll show you all the available events for that control; select a pair, and it automatically adds the template for that code block for you if it's not already defined, or navigates to it if it's there already. I've seen that there is a way of adding such a code block for control events (selecting through the properties window), but there appears to be no way to do it for form-level events. Am I missing something? Is there any purpose at all to the left-hand dropdown in C#? Any purpose other than (ham-handed) navigation for the right-hand dropdown?

Must be C#-only developers responding, because this doesn't bother anyone. I asked around the office and no one knew either. Some said it may be a bug, but hard to believe MS would have left if there as long as I've been aware of it (I'm not totally new to C#, just never did anything big or from scratch). Yes, as I said above, I see that you can do control events and Windows form events using the Properties window. But why not page events? And again ... what is the purpose of that left dropdown? This likely only bothers someone who's used VB, where those dropdowns are functional and helpful shortcuts.

推荐答案

请看我对这个问题的评论:很难看出你是什么失踪。如果您确实需要使用设计器添加任何事件处理程序,则首先选择所需的控件。如果这种控制是形式或某些儿童控制,那绝对无关紧要。没有特殊的表单级别。然后,您需要激活属性窗口,该窗口显示控件的所有可访问成员,包括您可以处理的所有事件。单击属性网格上的相应事件并获取已添加到所选事件实例的调用列表中的代码块,因此将调用此块作为此事件的处理程序。比你只需添加这个处理程序的代码。



-SA
Please see my comment to the question: it's hard to see what you are missing. If you really need to add any event handler using the designer, you first select the control you need. It absolutely does not matter if this control is the form or some child control. There is no special "form level". Then you need to activate the "Properties" window which shows all the accessible members of your control, including all of the events you can handle. You click on the appropriate event on the property grid and obtain the code block already added to the invocation list of the chosen event instance, so this block will be called as the handler of this event. Than you just add the code for this handler.

—SA


这篇关于Visual Studio C#UI快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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