Development of the login window in Delphi, how to make a form with a combobox?

Good evening everyone! Kind people, prompt please how to create this login form? User selection made from the Combobox, and the button enter should click on the form, which is designed for example for the doctor, if head select, then the login button navigates to the form of the head and so on. There are 4 user :the Registrar,the Manager , the doctor and the Accountant, help with code please! 5c992a1834bf5978714935.png
March 19th 20 at 08:33
1 answer
March 19th 20 at 08:35
Solution
procedure TMainForm.EnterButtonOnClick(Sender: TObject);
var
 Forms: array of TForm;
begin
 Forms := [RegistrarForm, ManagerForm, DoctorForm, AccountantForm]; // your form
Forms[Combobox.ItemIndex].ShowModal();
end;
What's wrong, please tell me 5c993635efb36997089651.png - sallie.Olson commented on March 19th 20 at 08:38
@sallie.Olson, maybe you have an older version of Delphi that does not support array literals
then it is possible so
procedure TMainForm.EnterButtonOnClick(Sender: TObject);
var
 Forms: array of TForm;
begin
 SetLength(Forms, 4);
 Forms[0] := RegistrarForm;
 Forms[1] := ManagerForm;
 Forms[2] := DoctorForm; 
 Forms[3] := AccountantForm;
Forms[Combobox.ItemIndex].ShowModal();
end;
- lourdes commented on March 19th 20 at 08:41
@lourdes, for a Minute, trying - sallie.Olson commented on March 19th 20 at 08:44
@lourdes, Yes, that compiles, but clicking the button throws the following error, I apologize for the molestation, what is wrong? :(5c9939a582b3b736261609.png - sallie.Olson commented on March 19th 20 at 08:47
@sallie.Olson, SetLength remember? - lourdes commented on March 19th 20 at 08:50
@lourdes, 5c993a966d17f786705430.png - sallie.Olson commented on March 19th 20 at 08:53
@sallie.Olson, the fact that I forgot another line to add, and you have inserted it before I edited
look again my previous comment - lourdes commented on March 19th 20 at 08:56
@lourdes, Oh! Exactly!!! Eyes already stick together I see nothing.. Huge thanks to You for the help in this late hour! Sincerely thank you! - sallie.Olson commented on March 19th 20 at 08:59
@sallie.Olson, note, please, if you got the answer - lourdes commented on March 19th 20 at 09:02
@lourdes, Optional) - sallie.Olson commented on March 19th 20 at 09:05
@sallie.Olson, Oh, I forgot about memory release
at the end add the line SetLength(Forms, 0);
I do not remember, whether there is a need for Delphi to free dynamic arrays, but rather add) - lourdes commented on March 19th 20 at 09:08
@lourdes, Good))Thanks!! - sallie.Olson commented on March 19th 20 at 09:11

Find more questions by tags User identificationDelphi