How to subclass TcxGridDBTableView and consume it without losing my GUI setup and installing it as component?
Using dev express makes it really easy to extend the Quantum Grid Views as described in
http://devexpress.com/Support/Center/KB/p/A334.aspx开发者_运维技巧?searchtext=viewinfo
you just have to declare and overwrite the methods you need:
TMyGridDBTableView = class(TcxGridDBTableView)
protected
function GetViewInfoClass: TcxCustomGridViewInfoClass; override;
end;
But in order to cosume the TMyGridDBTableView you either
- have to install it as a component package with RegisterComponent()
or build the whole UI from code like this
View := Grid.CreateView(TMyGridDBTableView) as TMyGridDBTableView; View.OptionsView.ColumnAutoWidth := True; View.OptionsView.NewItemRow := True; View.DataController.DataSource := DataSource1; View.DataController.CreateAllItems;
Neither of the ways is good to me because:
- I dropped installation of components in the IDE years ago due to unwillingness to rebuild, reinstall them after each small change and even though I write lots of components I initialize them with code
- I still install the dev express components though and manipulate them through the UI. Having to switch to pure source code instantination of all views will result in literally thousands of lines of code.
Is there a way I keep my already form-designed TMyGridDBTableView but enhanced them at runtime with the TMyGridDBTableView overloaded methods?
Installing your own component in the IDE is tried and tested. Many thousands of developers around the globe do it. I do it too. It works fine. You actually know this yourself since you do exactly that with the devexpress components.
However, if you are dead set against registering your own components in the IDE, you can use an interposer as Sertac suggested. This works so long as you don't need to publish any new properties, which I believe is the case in the situation you describe.
It's possible that the problems you have with registering components in the IDE are actually faults in your code. That's not meant as criticism, coding for design time behaviour is quite challenging. Since you don't need to publish new properties, and since the component in question is a third party component, an interposer or similar seems to be quite a reasonable approach.
精彩评论