Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Get Form Name as  variable and Open the Form

Posted on 2000-03-05
9
Medium Priority
?
264 Views
Last Modified: 2010-04-04
I'm using a ListView component with multiple items in it. The contents of the ListView depends on what item is selected in a TreeView. (So the ListView can change dynamically.) I want to link every item in the listview to a form name, and then depending on what item gets double clicked, the associated form must open. Is it possible to do this without If..Then or Case etc. statements, as I'm talking about a lot of forms here! I was hoping to use a variable or something that gets the form name from the SubItem of the Treeview and then create the form. Please Help Urgently!!
0
Comment
Question by:jannie030200
9 Comments
 
LVL 6

Expert Comment

by:edey
ID: 2586084
Name is the name of the control as referenced in the application’s code.

TComponentName: string;
property Name: TComponentName;



GL
Mike
0
 

Expert Comment

by:zb_russia
ID: 2586400
Sample:

  case ListView.Selected.Index of
    0: begin
      dlgGetCodeCard := TdlgGetCodeCard.Create( Self );
      try
        if ShowModal = mrOk ...
      finally
        dlgGetCodeCard.Free;
      end;
    end;
    1: begin
      ...
    end;
  end;


0
 

Author Comment

by:jannie030200
ID: 2587060
Thanks Zb, but the reason why I don't want to use case statements for this (as I mentioned in my original question) is that the index of the selected Item may vary depending on what user is logged on to the program. So it is impossible to link say ViewList.Selected.Index (say selected index = 0) to a fixed frmName, because when the next user logs on that very same item might have an index of say 10. I hope this clarifies the problem a bit. If it is possible to do something with the case statement and I'm just being stupid, can you please give me a bit more of the code I need to do this.

I think that maybe Edey's comment is a step in the right direction, but I'm quite new to the Delphi Environment and haven't got the foggiest as to how to declare properties..

Thx
Jannie
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2587084
hi jannie,

each node has a data-property (type pointer). here you can append all you need also objects(forms) or typed records.

meikl
0
 

Author Comment

by:jannie030200
ID: 2587118
Thanks Zb, but the reason why I don't want to use case statements for this (as I mentioned in my original question) is that the index of the selected Item may vary depending on what user is logged on to the program. So it is impossible to link say ViewList.Selected.Index (say selected index = 0) to a fixed frmName, because when the next user logs on that very same item might have an index of say 10. I hope this clarifies the problem a bit. If it is possible to do something with the case statement and I'm just being stupid, can you please give me a bit more of the code I need to do this.

I think that maybe Edey's comment is a step in the right direction, but I'm quite new to the Delphi Environment and haven't got the foggiest as to how to declare properties..

Thx
Jannie
0
 

Author Comment

by:jannie030200
ID: 2587146
hi meikl

I feel like an idiot at this point in time but I'm really lost here!

I see that the data property thing will work. If I got a table that looks something like this:
ID  Descr     FormName
1   Options   frmOptions
2   Setup     frmSetup  etc etc

If the Item in the ListView has got the caption of the descr for eg. 'Options' , I can obviously lookup the record in the table and then see that 'frmOptions' is associated with the ListView Item. The FormName is stored as Text. How can I Read that FormName into the Data Property of the Item and use that Data property to open a form when I double click the Item.

If you can, please include some code to help me understand this.
Cheers.
0
 

Accepted Solution

by:
zb_russia earned 150 total points
ID: 2587246
I are sorry for bad English, I not absolutely correctly have understood your question (small colloquial practice).

As it seems, there is a most simple mode to load the form, on her name (not the variant is considered, when there is a loading of a stream, the names of classes and so on) are formed dynamically. It - all the same problem case/of.

How it is possible to receive a name of a charged window? If this window is present as a name of the element in ListView (then we simple use ListView.Selected.Name) and then through if Name = " we discover the outcome, necessary to us.

If we use a not obviously circumscribed name (as in your example), then the intermediate array (or table) is used, that again a problem to reduce to a call of the chosen window.

For a case with a loading from a stream (the storage of the form in a data base) me needs to be re-read Rey Konopka, I now fast can not recollect singularities of a realization of a loading and unloading of the form in a stream.
0
 
LVL 3

Expert Comment

by:julianpointer
ID: 2589493
When are you creating each form ...

do you have some code like this to create each instance of a form

Form:=TForm.Create(self)
Form.Show;


or do you load each form when the  application is created.

0
 

Author Comment

by:jannie030200
ID: 2591997
Hi Julian,

the forms should bw created at runtime and by looking at your statement,
Form:=TForm.Create(Self)
Form.Show;

I need Form to be anything depending on what Item in the listview gets double clicked for eg.

frmMain := TfrmMain.Create(Self) and then the next time i click on the Icon it might need to execute something lik

frmNew := TfrmNew.Create(self);
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question