Solved

Get Form Name as  variable and Open the Form

Posted on 2000-03-05
9
254 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now