2

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

  1. have to install it as a component package with RegisterComponent()
  2. 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:

  1. 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
  2. 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?

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365
Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
  • Possibly a duplicate of [Replacing a component class in delphi](http://stackoverflow.com/questions/4685863/replacing-a-component-class-in-delphi) – Sertac Akyuz Aug 02 '11 at 23:12

1 Answers1

5

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.

Community
  • 1
  • 1
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • @sertac modesty mostly. If you've got a common base class for all your forms then the reader component class approach is simply better, no doubt in my mind. If you are using TForm as your anchor then imterposer may be easier.using TForm as your anchor then imterposer may be easier. – David Heffernan Aug 03 '11 at 00:12
  • Thanks for answering my comment asking "why did you rule out your answer on the mentioned question". :) – Sertac Akyuz Aug 03 '11 at 09:07
  • Interposer is more appropriate in my case since I have to intercept at least 4 consequitive called classes. I tried TVirtualMethodInterceptor as well but it seems to work only on TComponent instances nt just any class. – Gad D Lord Aug 03 '11 at 20:59