Re: TZF - tzListBox

Philip Kidder <[email protected]> Thu, 6 Nov 2003 08:18:21 -0500
Newsgroups gmane.comp.lang.delphi.topaz
Message-ID <[email protected]>
Bob,

Thanks for the explanation, but it is not the way I would design a listbox. Most of the time I want to pick from the items in a database not update a field in a database.

I still think it should load automatically from the file and allow me to set a filter.

Phil

  ----- Original Message ----- 
  From: [email protected] 
  To: [email protected] 
  Sent: Wednesday, November 05, 2003 9:36 PM
  Subject: Re: TZF - tzListBox


  Hi Phil - Comments Embedded 
  Bob Watson

  In a message dated 11/05/2003 12:06:47 PM Eastern Standard Time, [email protected] writes:



    Hello,

    I admit I can be dumb sometimes, usually more often then not, but can 
    someone explain to me how to use tzListBox?

    I have defined the datasource and the datafield which I would think 
    would automatically load the list but it doesn't. I found a procedure 
    tzMyList.Items.LoadFromFile (filename) but it generates a cannot open 
    file error. 


  BOB's NOTE:
  No - the TzListBox is loaded from a property of the componenet named
  ITEMS ... you can click the ellipses and get to a string editor and enter
  as many items for the list as you like.  You also associate the component
  with a field in a data base and then when you pick something from the 
  list, it alters the field in the database.





    What I did was add some code to the forms show procedure to pass through 
    the database and add items to the list. When I display the list I cannot 
    move down the list to pick the item I want. (I am filtering the items to 
    add to the list since I don't want to display all of them.)




  BOB's NOTE:
  I always fill up my list on the ACTIVATE event of the main form, assuming
  I am filling them from a file - even the TzListBoxes in other than the main form.
  My code looks something like this in the activate event.


  procedure TForm1.FormActivate(Sender: TObject);
  begin

    if FileExists('location.txt') then
    begin
      TzListBox1.Items.Clear;
      TzListBox1.Items.LoadFromFile('location.txt');
    end;
  end;

  If the file   LOCATION.TXT   does not exists then
  the items already loaded at design time will be
  available.

  If, for some reason, you need to know the item
  selected you can find it with (assuming you want it
  in edit1)

          edit1.text:=TzListBox1.Items[TzListBox1.ItemIndex]

  (Of course the item selected will be placed in the database
  field automatically.)
  Before doing the above you would want to check ItemIndex and make 
  sure it is not   -1   which means nothing is selected and would
  cause a run time error.

  Hope this helps,
  Bob Watson




    What is the trick to linking a tzListBox to a database and loading the 
    data automatically or with as little fuss as possible.

    Thanks!

    Phil Kidder

--^----------------------------------------------------------------
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------