DataGridView为readonly,如何能实现它的继承?

解决方案 »

  1.   

    当你拖放一个控件到form的时候,就会有两个对象被创建,一个是该控件,另一个就是该控件所绑定的ComponentDesigner,IDE判断ComponentDesigner的InheritanceAttribute属性值来决定是否将该控件标示为readonly继承。修改ComponentDesigner的InheritanceAttribute就行了
      

  2.   

    那意思就是说:继承ComponentDesigner是这样的吗?那GridView怎么样来继承呢?给个小代码可以吗?谢谢。public myDesigner:ComponentDesigner
    {
    proteced override InheritanceAttribute InheritanceAttirbute
    {
    get{
     if(base.InheritanceAttribute == InheritanceAttribute.InheritedReadonly)
       return InheritanceAttribute.Inherited;
    else
    base.InheritanceAttribute;
    };
    }
    }
      

  3.   

    继承ComponentDesigner是这样写的吗?那GridView怎么样来继承呢?给个小代码可以吗?谢谢。 public myDesigner:ComponentDesigner 

    proteced override InheritanceAttribute InheritanceAttirbute 

    get{ 
     if(base.InheritanceAttribute == InheritanceAttribute.InheritedReadonly) 
       return InheritanceAttribute.Inherited; 
    else 
    base.InheritanceAttribute; 
    }; 

    }
      

  4.   

    GridView并不是seald或者readonly哦。
      

  5.   

    所以你能直接继承来实现你的需求啊。ComponentDesigner是这样写。没错。这个我也是看过一本书上写的。呵呵
      

  6.   

    我个东西这里有玩过,去baidu这个ASPNetRealWorldContr下就知道了
      

  7.   

    也可以联系我,我给你发,email:[email protected]
      

  8.   

    GridView我还真没研究过。不过可以试试。楼主也可以结贴了吧。
      

  9.   

    直接继承是不行的,我试了,属性里面灰蒙蒙的一片。改成protected或public也是一样,用ComponentDesigner结果怎么都说找不到命名空间。看来这种继承还不如用用户控件实现。