🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.aspdotnet.components.using
4 messages
4 total messages Started by Rise Wed, 05 Oct 2005 13:41
TDropDownList - Adding Items
#98
Author: Rise
Date: Wed, 05 Oct 2005 13:41
5 lines
1187 bytes
Is it possible to manually add items to a TDropDownList (.NET webcontrol) 
without having to use a datasource? I can't find any Items.Add procedure or 
anything similar.

Could someone please point me in the right direction? 
Re: TDropDownList - Adding Items
#99
Author: Rise
Date: Wed, 05 Oct 2005 13:58
18 lines
1544 bytes
I just read

" all List-type Web Controls have a property called Items, which is a 
collection of the list items held within that control. To add an item to the 
end of the control's list, you use the Add method. "

The .Add property doesnt even exist. Im so confused...



"Rise" <rise@westnet.com.au> wrote in message 
news:4343d785@newsgroups.borland.com...
> Is it possible to manually add items to a TDropDownList (.NET webcontrol) 
> without having to use a datasource? I can't find any Items.Add procedure 
> or anything similar.
>
> Could someone please point me in the right direction?
> 
Re: TDropDownList - Adding Items
#200
Author: Marco Caspers
Date: Wed, 05 Oct 2005 17:45
30 lines
1976 bytes
Rise wrote:

> I just read
> 
> " all List-type Web Controls have a property called Items, which is a
> collection of the list items held within that control. To add an item
> to the end of the control's list, you use the Add method. "
> 
> The .Add property doesnt even exist. Im so confused...

.Add is not a property.

.Add is a Method.

And it is a method of the Items collection, not a method of the
component.

So if your component is a ListBox, the way you add an item to the list
is by calling ListBox.Items.Add(AnItem).

AnItem must be of the correct type. In the example of a listbox AnItem
is of type ListItem.

Note that none of the .NET components/classes etc. have a 'T' in front
of the class/component type name, this is because it's all Microsoft
Stuff, virtually nothing in asp.net in the pro sku is from Borland.


HtH,
Marco.
Re: TDropDownList - Adding Items
#206
Author: Rise
Date: Thu, 13 Oct 2005 02:24
55 lines
2672 bytes
Hi Marco, unfortunately you are incorrect. The .Add method does not exist. 
This is how you add...

Took me 3 hours to workout...but it works perfect :) :P

var
  ClientListArray: array of System.Web.UI.WebControls.ListItem;
  ClientDB: TClientDB;
  ClientList: TList;

Begin

SetLength(ClientListArray, ClientList.Count);

  for Loop := 0 to ClientList.Count - 1 do
  begin
    ClientListArray[Loop] := ListItem.Create('moo1', 'moo2');
  end;

  DropDownList1.Items.AddRange(ClientListArray);



"Marco Caspers" <HexorHaxor@Vaxor.Com> wrote in message 
news:43441136$1@newsgroups.borland.com...
> Rise wrote:
>
>> I just read
>>
>> " all List-type Web Controls have a property called Items, which is a
>> collection of the list items held within that control. To add an item
>> to the end of the control's list, you use the Add method. "
>>
>> The .Add property doesnt even exist. Im so confused...
>
> .Add is not a property.
>
> .Add is a Method.
>
> And it is a method of the Items collection, not a method of the
> component.
>
> So if your component is a ListBox, the way you add an item to the list
> is by calling ListBox.Items.Add(AnItem).
>
> AnItem must be of the correct type. In the example of a listbox AnItem
> is of type ListItem.
>
> Note that none of the .NET components/classes etc. have a 'T' in front
> of the class/component type name, this is because it's all Microsoft
> Stuff, virtually nothing in asp.net in the pro sku is from Borland.
>
>
> HtH,
> Marco. 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads