设计器生成的方法可以从 usercontrol.designer.vb 移动到 usercontrol.vb 吗? [英] Can a designer-generated method be moved from usercontrol.designer.vb to usercontrol.vb?

查看:16
本文介绍了设计器生成的方法可以从 usercontrol.designer.vb 移动到 usercontrol.vb 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要向 VB .Net UserControl 的 Dispose() 事件添加额外的代码.如何在不与设计器生成的代码发生冲突的情况下执行此操作?

I have need to add additional code to the Dispose() event of a VB .Net UserControl. How can I do this without coming into conflict with the designer-generated code?

是否可以将事件从 usercontrol.designer.vb 移动到 usercontrol.vb..?或者,有没有办法在两个文件之间拆分事件,或者告诉设计者不要生成该事件..?或者,覆盖覆盖可以这么说,在部分类到主要类之间..?

Can the event be moved from usercontrol.designer.vb to usercontrol.vb..? Alternatively, is there a way to split the event between the two files, or tell the designer not to generate that event..? Or, override the override so to speak, between the partial class to the main one..?

推荐答案

在与用户@jmcilhinney 评论我的 OP 时,答案是这样的:

In commenting with user @jmcilhinney on my OP, the answer is this:

Dispose() 方法可以从 usercontrol.designer.vb 移动到 usercontrol.vb 没有问题.原因如下:

The Dispose() method can be moved from usercontrol.designer.vb to usercontrol.vb without issue. The reason for this is as follows:

设计器代码文件......经常重新生成......包括当且仅当其中没有 Dispose 方法时才生成 Dispose 方法用户代码文件.

The designer code file ... gets regenerated often and ... that includes generating a Dispose method if and only if there isn't one in the user code file.

所以在移动之后,Dispose可以随意修改,并且不会被设计者重新生成和/或被随后对UserControl的任何更改覆盖.

And so after moving, Dispose can be modified at will, and it will not be regenerated and/or overwritten by the designer by any subsequent changes to the UserControl.

这篇关于设计器生成的方法可以从 usercontrol.designer.vb 移动到 usercontrol.vb 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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