SharpDevelop 中的事件名称

发布于 2024-09-04 03:07:43 字数 158 浏览 10 评论 0原文

我想问 abt Sharpdevelop。 我可以在 Sharpdevelop 中更改控件的事件名称吗?我想像在视觉工作室中一样添加“_”。 例如,Sharp开发中的按钮单击事件默认为Button1Click。我可以像 Visualstudio 中那样更改为 Button1_Click 吗? 谢谢。

i want to ask abt Sharpdevelop.
Can i change the control's event name in sharpdevelop ? I want to add "_" like in visual studio.
For Example, button click event in Sharp develop defaulted to Button1Click. can i change to Button1_Click like in visualstudio ?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

停顿的约定 2024-09-11 03:07:43

Mike Webb 的答案是在不修改 SharpDevelop 源代码的情况下生成带下划线的事件处理程序方法名称的唯一方法。

Lex Li的回答也是正确的。 SharpDevelop 中没有选项可以自动生成使用下划线的事件处理程序方法名称。目前唯一的办法就是修改源码。这是一个相当简单的代码更改。

  1. 下载SharpDevelop 源代码

  2. 提取代码。

  3. 找到 EventBindingService 类 (src\AddIns\DisplayBindings\FormsDesigner\Project\Src\Services\EventBindingService.cs)

  4. 找到 CreateUniqueMethodName 方法。

  5. 修改该方法中的单行代码,在字符串格式中使用下划线:

    return String.Format("{0}_{1}", Char.ToUpper(component.Site.Name[0]) + component.Site.Name.Substring(1), e.DisplayName) ;
    
  6. 通过运行 src\DebugBuild.bat 或 src\ReleaseBuild.bat 从源代码构建 SharpDevelop

然后,当您使用 SharpDevelop 的自定义版本并双击表单设计器中的按钮时,例如,您将获得一个名称如下的事件处理程序“按钮1_单击”。

在未来的某个时候,SharpDevelop 4 将允许通过可以在“工具”-“选项”中选择的选项来实现此目的。

Mike Webb's answer is the only way to generate an event handler method name with an underscore without modifying SharpDevelop's source code.

Lex Li's answer is also correct. There is no option in SharpDevelop to enable automatic generation of event handler method names that use an underscore. The only way currently is to modify the source code. It is a fairly straightforward code change.

  1. Download the source for SharpDevelop.

  2. Extract the code.

  3. Locate the EventBindingService class (src\AddIns\DisplayBindings\FormsDesigner\Project\Src\Services\EventBindingService.cs)

  4. Locate the CreateUniqueMethodName method.

  5. Modify the single line of code in this method to use an underscore in the string format:

    return String.Format("{0}_{1}", Char.ToUpper(component.Site.Name[0]) + component.Site.Name.Substring(1), e.DisplayName);
    
  6. Build SharpDevelop from source code by running src\DebugBuild.bat or src\ReleaseBuild.bat

Then when you use your customised version of SharpDevelop and double click a button in the forms designer, for example, you will get an event handler with a name like "Button1_Click".

At some point in the future SharpDevelop 4 will allow this with an option that can be selected in Tools - Options.

月竹挽风 2024-09-11 03:07:43

是的。如果您进入设计并在属性窗口中查找控件,您将在顶部看到一些图标。其中之一应该为您提供事件列表(在 VS 中它是一个闪电)。左侧列是可链接事件,右侧列是触发事件时调用的函数。

只需重命名左侧字段,并确保代码中的函数命名正确即可。您还可以在左侧字段中输入名称,然后在其中双击以自动生成该函数。

Yes. If you go into design and look in the properties window for the control you will see a few icons at the top. One of these should give you the list of events (in VS it is a lightning bolt). In the left hand column are the linkable events and in the right hand column are the functions that are called when the events are triggered.

Simply rename the left hand field and make sure you have the function named correctly in code as well. You can also type a name into the left hand field and then double click inside it to generate the function automatically.

淡淡绿茶香 2024-09-11 03:07:43

下划线对某些人来说是邪恶的,比如我:)

好吧,如果你确实想要下划线,请查看 SharpDevelop 源代码并找到该部分并修改它。它是开源的,所以你可以做任何你喜欢做的事情来取悦自己。我没有在某处看到可用的设置,因此修改源代码似乎是实现目标的唯一方法。

The underscore is evil to some people, like me :)

Well, if you do want the underscore, check out SharpDevelop source code and locate that part and modify it. It is open source, so you can do whatever you like to please yourself. I did not see a setting available somewhere, so modify the source code seems to be the only way to achieve your goal.

披肩女神 2024-09-11 03:07:43

我知道这是一个旧线程,但在 SharpDevelop v4.3 (v4.x - v5.x) 中有一个解决方案。过去我不得不使用上述方法,但是这个方法更快更容易。

启动 SharpDevelop 并检查以下设置

工具 >选项> Windows 窗体设计器 >一般> “生成 Visual Studio 样式事件处理程序

I know this is an old thread but in SharpDevelop v4.3 (v4.x - v5.x) there is a solution to this. In the past i've had to use the above method, however this one is much faster and easier.

Launch SharpDevelop and check the following setting:

Tools > Options > Windows Forms Designer > General > "Generate Visual Studio Style Event Handlers"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文