• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

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
0
christimage
Asked:
christimage
  • 3
  • 3
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now