Newbie Questions

1-I am trying to add a new form!
how to do that, I went NEW >> FORM and I got a new one. but each time I type Form2. in Form1 this error gets in the way
Form2 is in Unit2 and form1 in unit1
is that sapposed to be like this?

Build
  [Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source code

2- In VB there is ListBox which is MemoBox in Delphi
There is also ListView, what is it in delphi? and how to use it?
The difference ListView has many columns not only many rows, each column may have a title...
instant_newAsked:
Who is Participating?
 
DeNavigatorCommented:
You should place this code in the OnCLick Event of a button like:
procedure TForm1.Button1Click(Sender: TObject)
begin
  Form2 := TForm2.Create(self);
  try
    Form2.ShowModal;
  finally
    Form2.Free;
  end;
end;

This should clear your bugs. :)
0
 
DeNavigatorCommented:
What error do you get?

Maybe this is your solution:
add unit2 to the uses clause in the implementation section of unit1
then do something like:

begin
  Form2 := TForm2.Create(self);
  try
    Form2.ShowModal;
  finally
    Form2.Free;
  end;
end;
0
 
DeNavigatorCommented:
Second part:
ListView is also a component in Delphi on the Win32-tab. If you want columns put de view style to vsReport. You can (and must) add the columns via the columns property
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
moorhouselondonCommented:
If you click on the Form, press F11, you will see the Name of the form is Form1.  Try changing it to something else there.  But if you want to change the Main Form then this can be changed in Project, Options, Forms, Main Form.

The Unit name is when you pull down and Save the pas file, and this can be called something more meaningful too (but not the same name as the form - I stick an f in front for the Form).
0
 
moorhouselondonCommented:
"But if you want to change the Main Form then this can be changed in Project, Options, Forms, Main Form."

Let me clarify that:  ...if you want to change where the program starts running from then this can be changed....
0
 
TheRealLokiSenior DeveloperCommented:
you need to add "uses Unit2" in your unit 1 "uses" clause at the top.
If you need to see form1 from form2, you will need to add 'uses uni1" in the "implementation section (not at the top)
otherwise you will get a circular reference

TListView is in the Win32 Tab of the component palette
Drop 1 on your form, and set it's ViewStyle to vsReport
you can now right click on the listview and add columns and items.
0
 
instant_newAuthor Commented:
the only one that worked is DeNavigator's answer but it has problems
Im getting
Build
  [Error] Unit1.pas(23): Undeclared identifier: 'self' //<< Form2 := TForm2.Create(self);
  [Error] Unit1.pas(29): '.' expected but ';' found //<< end;
  [Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'
I changed self to Form2, but I still have the second problem.
can you help?
0
 
instant_newAuthor Commented:
solved the problem
thanks all
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.