Get the Selected Item Text from the treeview control


Does anyone know how to Get the Selected Item Text from the treeview control In C++ Builder

I'm working with files and when I try to open a file with this function with this funtion.


void TFotosysManager::Foton_Open(int Rood, int Geel, int Blauw, int Papier, string status, int MPapier, int MRood, int MGeel, int MBlauw, string IPadr, float Kosten, string locatie)
{
        String file;
        signed int i;
        file = "foton";
        file += TreeView1->Selected->Item[i]->Text;
        file  += ".fotosys";

        ifstream foton(bestand.c_str(), ios::in);

        foton >> Rood  >> Geel  >> Blauw >> Papier >> status >> MPapier >> MRood >> MGeel >> MBlauw >> IPadr >> Kosten >> locatie;

}

I get ERROR:  comparring signed an unsigned value
christimageAsked:
Who is Participating?
 
TheRealLokiSenior DeveloperCommented:
I think it's "TreeView1->Item[i]->Selected" not "TreeView1->Selected->Item[i]->Selected"
btw, you have **   if (TreeView1->Selected->Item[i]->Selected, i++)
but I think what you really want is a for-loop
I forget the code, but it would go something like

for(int i=0; i<(Treeview1->Items->Count-1); i++)
{ if (TreeView1->Item[i]->Selected)
        {
        file = "foton";
        file += TreeView1->Selected->Text;
        file += ".fotosys";
        ifstream foton(bestand.c_str(), ios::in);

        foton >> Rood  >> Geel  >> Blauw >> Papier >> status >> MPapier >> MRood >> MGeel >> MBlauw >> IPadr >> Kosten >> locatie;

        }
 }
forgive me, i dont have c builder handy
0
 
TheRealLokiSenior DeveloperCommented:
isn't it just TreeView1->Selected->Text
or TreeView1->Items[i]->Selected->Text
if you wish to check each node
0
 
christimageAuthor Commented:
Yes that is it I believe but I thing that I have another problem because I'm getting an acces Violation Error.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
christimageAuthor Commented:
Yes that is it I believe but I thing that I have another problem because I'm getting an acces Violation Error.


void TFotosysManager::Foton_Open(int Rood, int Geel, int Blauw, int Papier, string status, int MPapier, int MRood, int MGeel, int MBlauw, string IPadr, float Kosten, string locatie)
{
        String file;
        file= "foton";
        file += TreeView1->Selected->Text;
        file += ".fotosys";
        ifstream foton(bestand.c_str(), ios::in);
        foton >> Rood  >> Geel  >> Blauw >> Papier >> status >> MPapier >> MRood >> MGeel >> MBlauw >> IPadr >> Kosten >> locatie;

}
0
 
TheRealLokiSenior DeveloperCommented:
you need to check if there is a node selected
something like
if assigned(Treeview1->Selected) then ...
or
if TreeView1->Selected <> nil then...
0
 
christimageAuthor Commented:
TheRealLoki its still giging me the same  thing acces violation. what I'm trying to do is to give the var file the selected tree Item text. I've been stuck with this for a while. Hope I get it working with some help. I get acces violation right at the start of the if statement.


void TFotosysManager::Foton_Open(int Rood, int Geel, int Blauw, int Papier, string status, int MPapier, int MRood, int MGeel, int MBlauw, string IPadr, float Kosten, string locatie)
{
      String bestand;
        int i=0;
 **   if (TreeView1->Selected->Item[i]->Selected, i++)
        {
        file = "foton";
        file += TreeView1->Selected->Text;
        file += ".fotosys";
        ifstream foton(bestand.c_str(), ios::in);

        foton >> Rood  >> Geel  >> Blauw >> Papier >> status >> MPapier >> MRood >> MGeel >> MBlauw >> IPadr >> Kosten >> locatie;

        }
   }



0
 
Scay7Commented:
Isnt this in the wrong section ?


:P
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.