C# Web User Control help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,
I have web user control (c# code-behind) and i'm trying to create a property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble with
the syntax, can someone please help me?

thanks,
rodchar
 
hey all,
I have web user control (c# code-behind) and i'm trying to create a property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble with
the syntax, can someone please help me?

thanks,
rodchar

Lets say the user control contains a ListBox or a DropDownList. Lets
also assume it's named lstValues. You can make this list available to
the form using the user control by providing a public property of the
lstValues Items property.

public ListitemsCollection Items
{
get { return lstValues.Items; }
}

This will expose the Items property to the form containing the user
control. You can now use the add method of this property to add items
to this list of items.

uc1.Items.add(mylistitem);

You can also iterate through it ...

foreach(ListItem li in ux1.Items)
 
is this possible with an enum list?

wmain said:
Lets say the user control contains a ListBox or a DropDownList. Lets
also assume it's named lstValues. You can make this list available to
the form using the user control by providing a public property of the
lstValues Items property.

public ListitemsCollection Items
{
get { return lstValues.Items; }
}

This will expose the Items property to the form containing the user
control. You can now use the add method of this property to add items
to this list of items.

uc1.Items.add(mylistitem);

You can also iterate through it ...

foreach(ListItem li in ux1.Items)
 
No problem.
Here's some sample code that should do the trick:

public enum AppType: int
{
HTML,
Word,
Excel,
PowerPoint,
WordPerfect
}

//Manage the requested export type
private AppType m_AppType;
[Bindable(true), Category("Behavior")]
public AppType ExportType
{
get
{
return m_AppType;
}

set
{
m_AppType= value;
}
}
 
Back
Top