Board index » delphi » Assign Index of ListBox to ListBox ???

Assign Index of ListBox to ListBox ???

I wanna assign index of objects of one ListBox to Another. But there is no
such a property Index or something like that. Please help !
 

Re:Assign Index of ListBox to ListBox ???


ListBox2.Items := ListBox1.Items

Quote
SnOOpY <sn0...@dir.bg> wrote in message

news:01bf9f06$99b10a80$0500a8c0@vega...
Quote
> I wanna assign index of objects of one ListBox to Another. But there is no
> such a property Index or something like that. Please help !

Re:Assign Index of ListBox to ListBox ???


That doesn't assign(copy) the stuff from listbox1 to listbox2. It makes listbox1
and listbox2 ALIAS's of each other. Whatever happens to 1 happens to 2 because
you copied the pointer to the items over to listbox2.

Try this instead:

ListBox2.items.assign(LIstBox1.items);

Davie

Quote
Garron Mosley wrote:
> ListBox2.Items := ListBox1.Items

> SnOOpY <sn0...@dir.bg> wrote in message
> news:01bf9f06$99b10a80$0500a8c0@vega...
> > I wanna assign index of objects of one ListBox to Another. But there is no
> > such a property Index or something like that. Please help !

Re:Assign Index of ListBox to ListBox ???


Oh my. Then can anyone answer this, why is it that some do the behind the scenes and
others require you to do it implicitly? Why not be consistent?

Davie

Quote
"Mike Orriss (TeamB)" wrote:
> In article <38EBBC95.B6CE5...@smatters.com>, Davie wrote:
> > That doesn't assign(copy) the stuff from listbox1 to listbox2. It makes listbox1
> > and listbox2 ALIAS's of each other. Whatever happens to 1 happens to 2 because
> > you copied the pointer to the items over to listbox2.

> Not true in this case.

> Items is a property of ListBox and the SetItems method invoked calls Assign behind
> the scenes.

>  Mike Orriss (TeamB)
>  (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
>  (Unsolicited e-mail replies will most likely be ignored)

Re:Assign Index of ListBox to ListBox ???


Quote
In article <38EBBC95.B6CE5...@smatters.com>, Davie wrote:
> That doesn't assign(copy) the stuff from listbox1 to listbox2. It makes listbox1
> and listbox2 ALIAS's of each other. Whatever happens to 1 happens to 2 because
> you copied the pointer to the items over to listbox2.

Not true in this case.

Items is a property of ListBox and the SetItems method invoked calls Assign behind
the scenes.

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
 (Unsolicited e-mail replies will most likely be ignored)

Re:Assign Index of ListBox to ListBox ???


Quote
In article <38EC10E5.A7767...@smatters.com>, Davie wrote:
> why is it that some do the behind the scenes and
> others require you to do it implicitly? Why not be consistent?

It is consistent. Why expect variables and properties to be the same?

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
 (Unsolicited e-mail replies will most likely be ignored)

Re:Assign Index of ListBox to ListBox ???


Ah, ok, so Items is a property and as such it does an assign for
consistency and if it were a variable, it would just copy the pointer in
which case it would just be an alias of each other?

Davie

Quote
"Mike Orriss (TeamB)" wrote:
> In article <38EC10E5.A7767...@smatters.com>, Davie wrote:
> > why is it that some do the behind the scenes and
> > others require you to do it implicitly? Why not be consistent?

> It is consistent. Why expect variables and properties to be the same?

>  Mike Orriss (TeamB)
>  (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
>  (Unsolicited e-mail replies will most likely be ignored)

Re:Assign Index of ListBox to ListBox ???


Quote
In article <38EE42A3.88956...@smatters.com>, Davie wrote:
> Ah, ok, so Items is a property and as such it does an assign for
> consistency and if it were a variable, it would just copy the pointer in
> which case it would just be an alias of each other?

Correct.

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
 (Unsolicited e-mail replies will most likely be ignored)

Other Threads