Board index » delphi » Question - how to fill TMenuItems with Oracle table names at run time

Question - how to fill TMenuItems with Oracle table names at run time

Ok, here's what I have -
(This is going to be a really obvious answer and I'm going to feel
stupid...) :)

I need to fill a menu with my Oracle table names. I want to do this at
runtime to avoid having to re-code for different schemas.

I know how to get the names at run time, but how do I store them in a
TStringList to use them to build the menu? Or is this the wrong track?

Thanks in advance.

Mike
J.M. Blevins - Delphi programmer, ex - Paradox geek, musician,
and general hangover artist for CACI, Inc.

 

Re:Question - how to fill TMenuItems with Oracle table names at run time


Ok, here's what I have -
(This is going to be a really obvious answer and I'm going to feel
stupid...) :)

I need to fill a menu with my Oracle table names. I want to do this at
runtime to avoid having to re-code for different schemas.

I know how to get the names at run time, but how do I store them in a
TStringList to use them to build the menu? Or is this the wrong track?

Thanks in advance.

Mike
J.M. Blevins - Delphi programmer, ex - Paradox geek, musician,
and general hangover artist for CACI, Inc.

Re:Question - how to fill TMenuItems with Oracle table names at run time


eaeol...@crosslink.net (J. Michael Blevins) wrote:

Quote
> I need to fill a menu with my Oracle table names. I want to do this at
> runtime to avoid having to re-code for different schemas.

The way I do it, where Query1 is 'SELECT TABLE_NAME FROM USER_TABLES'
and Tables1 is a TMenuItem from TMainMenu:
...
var
  NewMenuItems: TList;
  RecCnt      : integer;
begin
  NewMenuItems := TList.Create;
  for RecCnt := 0 to Query1.RecordCount-1 do
    begin
      NewMenuItems.Add(TMenuItem.Create(Tables1));
      TMenuItem(NewMenuItems.Items[RecCnt]).Caption :=
        Query1.Fields[0].AsString;
      Tables1.Insert(RecCnt, TMenuItem(NewMenuItems.Items[RecCnt]));
      Query1.Next;
    end;
end;
...

Of course, you will have to free that list at some leter, suitable
time.

Good luck!

Jasper

Other Threads