Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > VCL

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2017, 11:34 AM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 234
Default How to update list in a combobox

Hi,

I have a combobox on an input-page for at database.
On another tabsheet I want to edit the Combobox list of items in a memo.

After edit I save the list and then load it into my combobox...

memo1.SavetoFil('cbList.txt');
combobox1.Items.LoadFromFile('cbList.txt');

but to my surprice it is not updated with my new data.

If I start the program again the list is updated because the Form.Create event has this code:

combobox1.Items.LoadFromFile('cbList.txt');

Does somebody know why I have to start the program Again in order to have my list updated. After all it is the same code!?

Best Regards
Lars - DK
Reply With Quote
  #2  
Old 02-17-2017, 01:55 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 159
Default

You don't have to save the Memo to file to allow the combobox to update it's contents.

Code:
ComboBox1.Items.Assign(Memo1.Lines);
ComboBox1.Items and Memo1.Lines are both TStrings so you can assign one to the other. That means you can also do
Code:
Memo1.Lines.Assign(ComboBox1.Items);
as a way to get the combobox items into the memo.
Reply With Quote
  #3  
Old 02-17-2017, 05:16 PM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 234
Default

Nice to know the easier way to with the assign syntax.
However my problem is solved by loading the changed file into the Combobox when entering it Again.

Last edited by larshgf; 02-18-2017 at 08:08 AM.
Reply With Quote
  #4  
Old 02-19-2017, 08:10 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 159
Default

What I provided does not in any way stop you from saving the changes to a file like you were before.

All I pointed out was that you didn't need to save it to file and then reload from the file.
Reply With Quote
  #5  
Old 02-19-2017, 08:13 PM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 234
Default

Yes I know, and I thank you for the tip :-)
(in fact you made me find the solution when I was looking at the problem once more)
BR Lars
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:57 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.