简体   繁体   English

RadGridViews事件处理的可视继承可能吗?

[英]Visual inheritance for RadGridViews event handling possible?

I have 2 projects: 我有2个项目:

  • Project A which consists of a Usercontrol named BaseUC which consists of a RadPanel and a RadGridView (both have modifier set to public) 项目A由一个名为BaseUC的用户控件组成,该用户控件由一个RadPanel和一个RadGridView组成(两者均已将修饰符设置为public)
  • Project B which consists of a Usercontrol which inherits from BaseUC (from the class itself). 项目B由一个UserControl组成,后者从BaseUC(从类本身)继承。 Project A is included as referenced dll in Project B 项目A作为项目B中的引用dll包含在内

Now the situation is so: 现在的情况是这样的:

  • Both elements from BaseUC are shown in the DerivedUC. 来自BaseUC的两个元素都显示在DerivedUC中。
  • The RadLabel I can edit without problems (properties) in project B 我可以在项目B中毫无问题地编辑RadLabel(属性)
  • The GridView has its properties grayed out in project B GridView的属性在项目B中显示为灰色
  • If I give GridView events which I implement as virtual in project A and overwrite them in project BI run into the problem that I get an exception as soon as I try to fire the events. 如果我给出在项目A中实现为虚拟的GridView事件,并在项目BI中将其覆盖,则会遇到这样的问题,即我尝试触发事件时会遇到异常。 Same if I try to manually add events to the gridview in project B. 如果尝试将事件手动添加到项目B中的gridview,则相同。

So my question is twofold there but comes down to the basic question if event handling is possible for visually inheritted RadGridViews: 所以我的问题是双重的,但归结为一个基本问题,即是否可以对可视继承的RadGridViews进行事件处理:

  1. How can I get the RadGridView to have its properties editable in design view in project B? 如何在项目B的设计视图中使RadGridView具有可编辑的属性?
  2. How can I handle events there? 我该如何处理那里的事件?

That is if these two things are possible at all. 那就是说,如果这两种事情都是可能的话。

You can expose the child controls contained in your UserControl as a public property, that is creating a public property that returns the child control and not just making the child variable public. 您可以将UserControl中包含的子控件公开为公共属性,即创建一个返回该子控件的公共属性,而不仅仅是使子变量公开。 This will make the child control available to sink event handlers and set public properties. 这将使子控件可用于接收事件处理程序并设置公共属性。 Note that this breaks one of object orientation rules namely, encapsulation....but rules are meant to be broken for certain cases that fits the requirement :) 请注意,这违反了面向对象的规则之一,即Encapsulation ....,但是在某些情况下要打破规则才能满足要求:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM