Board index » delphi » How to dynamic add Server to TSimpleObjectBroker component on run-time?

How to dynamic add Server to TSimpleObjectBroker component on run-time?

I want to code like this(of couse, it is a wrong version):

    SimpleObjectBroker1.Items.Add('192.168.0.16');
    SimpleObjectBroker1.Items.Add('127.0.0.1');
    ...

Would anyone tell me how? Thank you very much.

--
Best regards,
Diviner.

 

Re:How to dynamic add Server to TSimpleObjectBroker component on run-time?


Quote
In article <39502BC3.8DC7A...@hongkongconcrete.com.hk>, Man Chan wrote:

> I want to code like this(of couse, it is a wrong version):

>     SimpleObjectBroker1.Items.Add('192.168.0.16');

 With TServerItem( SimpleObjectBroker1.Servers.Add ) Do Begin
   Computername := '192.168.0.16';
   ...set other properties here
 End;  

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:How to dynamic add Server to TSimpleObjectBroker component on run-time?


I am sorry that I can't compile the code you provided. I checked the Add
method
will return TCollectionItem and no ComputerName property be there. Any
suggestions?
Quote
> In article <39502BC3.8DC7A...@hongkongconcrete.com.hk>, Man Chan wrote:

> > I want to code like this(of couse, it is a wrong version):

> >     SimpleObjectBroker1.Items.Add('192.168.0.16');

>  With TServerItem( SimpleObjectBroker1.Servers.Add ) Do Begin
>    Computername := '192.168.0.16';
>    ...set other properties here
>  End;

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!

Re:How to dynamic add Server to TSimpleObjectBroker component on run-time?


Quote
In article <3952CE47.BB735...@hongkongconcrete.com.hk>, Man Chan wrote:

> I am sorry that I can't compile the code you provided. I checked the Add
> method
> will return TCollectionItem and no ComputerName property be there. Any
> suggestions?

That is why i typecast the return value of Add to TServerItem, the class of
the TCollectionitems in the Servers collection. I did not test the code i
posted but am fairly confident that it will compile. You mentioned
SimpleObjectBroker1.Items in your original post but the TSimpleObjectBroker
class does not have an Items property, so i assumed you meant the Servers
property.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:How to dynamic add Server to TSimpleObjectBroker component on run-time?


I did it and get success. Thank you very much.

Quote
> In article <3952CE47.BB735...@hongkongconcrete.com.hk>, Man Chan wrote:

> > I am sorry that I can't compile the code you provided. I checked the Add
> > method
> > will return TCollectionItem and no ComputerName property be there. Any
> > suggestions?

> That is why i typecast the return value of Add to TServerItem, the class of
> the TCollectionitems in the Servers collection. I did not test the code i
> posted but am fairly confident that it will compile. You mentioned
> SimpleObjectBroker1.Items in your original post but the TSimpleObjectBroker
> class does not have an Items property, so i assumed you meant the Servers
> property.

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!

--
Best regards,
Diviner.

Other Threads