RadioGroup with Memo

Hello everybody :) I'm writing small application about mileage of Polish roads. I'm using C++Builder 6. My application looks like this:

http://s3.postimg.org/u8jp5l5cz/Bez_tytu_u.png

When I choose road from ComboBox, application load information to RadioGroup and Memo from text file, about mileage and polish province. Syntax of this file is:

1
2
3
4
5
6
37,4 - 41,8 km=Powiat Zgierski
41,8 - 362,9 km=Miasto Łódź
362,9 - 382 km=Powiat Łódzki Wschodni
399,8 - 416,1 km=Powiat Piotrkowski
416,1 - 447,5 km=Powiat Radomszczański
>> 447,5 km=Województwo Śląskie - Kierunek Częstochowa


And now I have problem with RadioGroup, because I want something like that: when user choose some option from RadioGroup I want to display correct value (province) in Memo or Label - it dosen't matter. Of course lists of mileage are different for different roads in Poland. It's not constants.

My code:

Uni1.h

1
2
private:	// User declarations
        THashedStringList *Lista;


Unit1.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void __fastcall TForm1::ComboBox3Select(TObject *Sender)
{
        //co zrobimy po wybraniu z listy dróg krajowych z ComboBox
        if (ComboBox3->ItemIndex == 0)
        {
                String sFileName = ExtractFilePath(ParamStr(0)) + "dat\\kraj1pik.dat";

                if(!FileExists)
                {
                        Application->MessageBox(("Nie odnaleziono pliku '" + ExtractFilePath(ParamStr(0)) + "dat\\kraj1pik.dat'!").c_str(), "Uwaga! Brak pliku", MB_OK | MB_ICONSTOP);
                        RadioGroup1->Items->Clear();
                        Memo1->Clear();
                        return;
                }

                Lista = new THashedStringList;
                Lista->LoadFromFile(sFileName);

                RadioGroup1->Items->Clear();
                Memo1->Clear();

                for(int i = 0; i < Lista->Count; i++)
                {
                        RadioGroup1->Items->Add(Lista->Names[i]);
                        Memo1->Lines->Add(Lista->Values[Lista->Names[i]]);
                }
                delete Lista;
        }
}


Help me, please :) Sorry for my English :)
1
2
3
4
5
6
7
8
9
10
11
12
13
				if ( lista == NULL)
					delete Lista;
				
                Lista = new THashedStringList;
                Lista->LoadFromFile(sFileName);

                RadioGroup1->Items->Clear();
                Memo1->Clear();

                for(int i = 0; i < Lista->Count; i++)
                {
                        RadioGroup1->Items->Add(Lista->Names[i]);
                }



create event on groupbox, like onChange, or onClick. Inside it find which radio button is selected and then use this:
1
2
3
4
5
				if ( lista != NULL)
				{
				//find selected radio button
				Memo1->Lines->Add(Lista->Values[ Lista->Names[  < here put selected radio button index >  ]]);
				}
Topic archived. No new replies allowed.