想扩展一下DATAGRIDVIEW的功能,但是怎么自己做一个控件,然后继承DATAGRIDVIEW那?
我新建一个控件项目,写INHERITS SYSTEM.WINDOWS.FORMS.DATAGRIDVIEW
提示出错,提示为
Error 1 Base class 'System.Windows.Forms.DataGridView' specified for class 'UserControl1' cannot be different from the base class 'System.Windows.Forms.UserControl' of one of its other partial types.
但是在2003里面就是可以这么写的,难道我必须继承system.windows.forms.usercontrol?
在VB2005新建项目时系统会自动产生一个名为(项目名).Designer.vb的文件(控件项目默认为UserControl1.Designer.vb)此文件多用于存放设计器产生的代码,默认情况下不可见。
而VB2005的设计器在新建控件项目时自动把“Inherits System.Windows.Forms.UserControl”一句写入该文件,所以楼主在使用“Inherits System.Windows.Forms.DataGridView”语句继承时就会出现错误。
解决办法:楼主可以打开上面所说的那个文件,然后把“Inherits System.Windows.Forms.UserControl”这一句屏蔽掉,即可。