rfwoolf
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?
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?
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(Ta ble1.Field ByName('Na me').AsStr ing);
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,
[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(Ta
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.De stroy;
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 .Activepag e.Tag).Var ArrayOf([T able1.Fiel ds[0].AsVa riant, 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 :-)
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.De
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
again
I have never come across a user friendly/easily customizable control that does what you are asking. Otherwise i would have suggested it :-)
ASKER
Thanks
ASKER
Thanks for the great solution RealLoki. Hopefully the team at JVCL and work on something like this.
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