Link to home
Start Free TrialLog in
Avatar of rfwoolf
rfwoolfFlag for South Africa

asked on

Data-aware Page control with 1 page per record?

Is there a data-aware component (preferably JVCL or similar) where I can have like a PageControl and have 1 page or tab per record?
So if my table has 5 records then there will be 5 pages?
Each page will then have some DBEdits and similar controls all laid out .
Of course these Data-Controls on the page will actually only be laid out on ONE page. Know what I mean?
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

it sounds to me like you don't really need the PageControl at all.
You just want the "tabs" so the user can press them and go to the appropriate record.
you could put the data aware controls in 1 panel and just dynamically create some buttons.
or, if you really wanted, you could use a TPageControl, but set its' height to 25 and use the OnChange event to change to the appropriate record
Avatar of rfwoolf

ASKER

Yes and then I have to populate the tabs on teh PageControl because they won't be data-aware?
I suppose I could do that but I was hoping for something data aware and fluid.
I have played with the DBCtrlGrid but it doesn't have tabs.
ASKER CERTIFIED SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rfwoolf

ASKER

Hmm.. thanks for that. It looks good. There are a few things that throw me out which means I would probably rewrite the whole thing...
[1] You 'used' contnrs which I don't know what that is and why you need it,
[2] I was playing with a PageControl and I couldn't seem to add any 'pages' in it using code - I can do this with TTabControls  by saying  tabcontrol1.Tabs.Insert( - so I would probably replace the PageControl with a TabControl. I think you create TTabsheets and then insert them O.o

So I would probably use a Tabcontrol and simply say
Table1.begin
While Table1.eof = false do
begin
  TabControl1.Tabs.Insert(Table1.FieldByName('Name').AsString);
  Table1.next;
end;

Of course, because the whole thing is not data-aware, if you delete a record (Table1.Delete) then you have to reprocess the Tabs. I was hoping for something data-aware and therefore more fluid, but so far this is the best bet
>  [1] You 'used' contnrs which I don't know what that is and why you need it,
 contnrs is used for the TObjectList
 when an object is deleted from that list, it is also free'd
it just saves you doing this
while (mylist.count >0) do
begin
  mylist[0].free;
  mylist.delete(0);
end;

>   [2] I was playing with a PageControl and I couldn't seem to add any 'pages' in it using code - I can do this with TTabControls  by saying  tabcontrol1.Tabs.Insert( - so I would probably replace the PageControl >  with a TabControl. I think you create TTabsheets and then insert them O.o

yes, the way to add pages at runtime is create the page, then tell it what pagecontrol it belongs to
You can however, very easily "insert" it where you like just by setting its' "PageIndex"
eg.
Page.PageIndex := 0; // make this the first page

You can easily use a tabcontrol if you like. This was just a demo :-)

>  Of course, because the whole thing is not data-aware, if you delete a record (Table1.Delete) then you >  have to reprocess the Tabs
You can set an "OnDelete" event of the table/query that just does
PageControl1.ActivePage.Destroy;
likewise, if you wished to support "insering a new record" you would need to create a new tab.
and if the "key fields" change, you need to update the TTabKeyFields values for that tab
(as easy as using the table's OnPost event to do

TTabKeyFields(PageControl1.Activepage.Tag).VarArrayOf([Table1.Fields[0].AsVariant, Table1.Fields[1].AsVariant, Table1.Fields[2].AsVariant]);
again


I have never come across a user friendly/easily customizable control that does what you are asking. Otherwise i would have suggested it :-)
Avatar of rfwoolf

ASKER

Thanks
Avatar of rfwoolf

ASKER

Thanks for the great solution RealLoki. Hopefully the team at JVCL and work on something like this.