I have just started writing my first application in delphi and I am now stuck communicating between forms. I am using a serial port component TnrComms which has a main serial port component and a Device dropdown box component. I wish to select the dropdown box on a different form in the same project, but I don't know how to reference the main serial port component so that I can select that component in the object inspector. Have a look and point me in the right direction.
type
TPortForm = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
Quit1: TMenuItem;
PortOk: TButton;
PortCancel: TButton;
nrDeviceBox1: TnrDeviceBox; //this is the dropdown box
private
{ Private declarations }
public
{ Public declarations }
end;
var
PortForm: TPortForm;
implementation
{$R *.dfm}
end.
Thanx
procedure TMainForm.OnCreate(Sender: TObject);
begin
nrComms1.assocDropdown:=Form2.nrDeviceBox;
end;
"assocDropdown" is the property name, the same like in the object inspector.
This should do it although I can not test it and I don't know your Delphi version either.
You have to set the form create order so that form2 will be created before form1 and connect the procedure above to the OnCreate handler of Form1.
hth,
M.
Hi M,
I managed to sort it out I added datacollex to the uses of dataform and added dataform was put in the implementation uses to stop circular references and that seem to this problem out. I do need some more advise, but will start a new post.