using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;namespace MyCombobox
{
        public class 
        ComboBase: System.Windows.Forms.ComboBox
        {
                System.Data.DataTable oTable = null;
                System.Data.DataView oDv = null;
                public ComboBase()
                {
                    SetIniDrop("disPlay", "valPlay");
                }
                private void SetIniDrop(string DisPlay, string ValPlay)
                {
                    oTable = new System.Data.DataTable("combo");                    oTable.Columns.Add(DisPlay, typeof(string));
                    oTable.Columns.Add(ValPlay, typeof(string));
                    oTable.Rows.Add(new object[] { "", "" });
                    oDv = new System.Data.DataView(oTable, "", "", System.Data.DataViewRowState.CurrentRows);
                    this.DataSource = oDv;
                    this.DisplayMember = DisPlay;
                    this.ValueMember = ValPlay;                }
                public void Add(string[] sender)
                {
                    oTable.Rows.Add(sender);
                }
                protected override void OnCreateControl()
                {
                    base.OnCreateControl();
                }
        }
}
以上是代码 抱错为:“MyCombobox.UserControl1.Dispose(bool)”: 没有找到适合的方法来重写我加了一下三种方法都不行
            1//public new void Dispose()
            //{
            //    base.Dispose();
            //    /*
            //     * 其他要释放的资源
             //     * */
            //}
            //public new void Dispose(bool trueOrFalse)
            //{
            //    base.Dispose(trueOrFalse);
            //    /*
            //     * 其他要释放的资源
              //     * */
            //}            2//protected override void Dispose(bool disposing)
            //{
            //    if (disposing)
            //    {
            //        if (components != null)
            //            components.Dispose();
            //    }
            //    base.Dispose(disposing);
            //}            3//protected override void Dispose(bool disposing)
            //{
            //    if (disposing)
            //    {
            //        if (components != null)
            //            components.Dispose();
            //    }
            //    base.Dispose(disposing);
            //}

解决方案 »

  1.   


    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Drawing; 
    using System.Data; 
    using System.Text; 
    using System.Windows.Forms; namespace ZipDemo
    {
        public class ComboBase: System.Windows.Forms.ComboBox 
        {
            System.Data.DataTable oTable = null;
            System.Data.DataView oDv = null;
            public ComboBase()
            {
                SetIniDrop("disPlay", "valPlay");
            }
            private void SetIniDrop(string DisPlay, string ValPlay)
            {
                oTable = new System.Data.DataTable("combo");            oTable.Columns.Add(DisPlay, typeof(string));
                oTable.Columns.Add(ValPlay, typeof(string));
                oTable.Rows.Add(new object[] { "", "" });
                oDv = new System.Data.DataView(oTable, "", "", System.Data.DataViewRowState.CurrentRows);
                this.DataSource = oDv;
                this.DisplayMember = DisPlay;
                this.ValueMember = ValPlay;        }
            public void Add(string[] sender)
            {
                oTable.Rows.Add(sender);
            }
            protected override void OnCreateControl()
            {
                base.OnCreateControl();
            }        protected override void Dispose(bool disposing)
            {
                oDv = null;
                oTable = null;
                base.Dispose(disposing);
            }
        }
    }你说的怎么在我这能通过编译呢。
    贴出来的代码在vs2005中通过编译了。
      

  2.   

    你给了public class  ComboBase的代码,但出错的却是UserControl1, 不是ComboBase
      

  3.   

    我就是新建一个名为:ComboBase 的控件库  然后在UserControl1.cs里面写的如上代码的   有什么问题吗?
      

  4.   

    把你编译成功的工程打包发给我   [email protected]   收到后立马结帖