Accessing protected members of component from Form

[b][red]This message was edited by Alien_SM at 2006-8-3 23:11:44[/red][/b][hr]
[b][red]This message was edited by Alien_SM at 2006-8-3 22:0:16[/red][/b][hr]
Hi All

This will be my first post in C++ Builder Msb Board

Ok so here is the question. I have been looking at the tutorials on the DB grid on They pull a trick there to accomplish allot of the nifty tricks:

Accessing protected members of a DBGrid
Windows, Messages, ..., Grids, DBGrids, ... ;

type THackDBGrid = class(TDBGrid);

TForm1 = class(TForm)
DBGrid1: TDBGrid;

Then late in same unit he uses the following lines
THackDBGrid(DBGrid1).RowHeights[0] := 20;
Ok off course that type of casting is not a good idea in C++ Builder. Event tried declaring a clean class and doing the same just to test.

I also tried the following:
typedef class THackGrid : TDBGrid
friend class TForm1;

Then in a event of one of the components like a button on the form:
THackGrid* Testing1;

Testing1 = dynamic_cast(DBGrid1);
Testing1->RowHeights[1] = 10;;

This causes a exception which is right if I think about it. But is something similar possible.



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion