Hi...I need to write dynamic menu...
which will take all items from ini/cfg gile
cfg file will look like that:

TEMPLATE_NAME=LEX UPDATE
PL=Czesc to jest update.
ENG=Hi this is uptade.

TEMPLATE_NAME=WINDOWS ERROR
PL=Blad
ENG=Error!
.
etc
.
.

Items will be read to dropdown menu called TEMPLATES..
I know how to do that.
I will modify my last code

StreamReader^ plik= gcnew StreamReader("CONFIG\\systems.ini",System::Text::Encoding::Default);
		    while (linia=plik->ReadLine()) 
		    {
		    this->systemBOX->Items->Add(linia);
		    }

I will add if linia contains "template=" then replace "template=" and add item..

but...
I dunno how to make it work.
for example templates in cfg may vary.(from 1 to 20 items)
when I click on item at dropdown menu, it should copy text from PL= & ENG= to textbox fields....
Its very easy to do when you have constant list defined in program...I dunno how to do it if its dynamic..an all parameters are taken from the file...

Please help.and thx in advance.

Before you start to do it all by hand, take a look at something like this http://msdn.microsoft.com/en-us/magazine/cc163991.aspx#S3. There are mechanisms in place for internationalization of your application and you can keep the strings right in the ResX file now, rather than using an external config file.

Otherwise, split the strings (String ^ has a split method) that you read in into an array of strings based on =, so you'll end up with: [PL],[String in Polish] so you can sort them out that way.

Hmm this is not exactly localization.
My program has two texboxes to fill - Polish texbox and english texbox...Both are used to replace several key words in html files...
my template dropdown menu + cfg file shlould be used to speed up filling them by providing several typical, most used texts in cfg file.(so u wont need it to type by hand).
Items and all text in program GUI are english.
PL= and ENG= corresponds with name of the tex boxes - Pl_texbox and Eng_texbox... and choosing option from teplate dropdown menu should copy PL text to one textbox and ENG text to second one...I know how to add items from the cfg files to menu...I dunno how to make dynamic events - because events depends on number of items loaded from cfg file...(in pure c++ i have used for loop for all items loaded to arrays, but it doesnt work here)

Edited 5 Years Ago by VasquezPL: n/a

How about using a List of lists (could be a list of value structs too):

List<List<String ^> >^ options = gcnew List<List<String ^> >(); 
List<String^>^ strgroup = gcnew List<String^>();
//loop over your file
//Add 3 lines into strgroup
//Add strgroup to options

This way you can access the members of a list with array notation (and the indexes will match up with the SelectedItem property of the dropdown menu).

I didn't compile that so I don't know if the syntax is spot on, but with the list you don't have to know how many you'll have at compile time. You could conceivably use a cli::array also, but I think the list has a more manageable interface.

This article has been dead for over six months. Start a new discussion instead.