473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

User Control - Having the collections show up in property window

I need help getting the collections to show up in the property window of a
user control. I want to be able to edit the collection items just like any
other asp.net control that has collection properties (i.e. The ASP:Table
control). This is for a menu system. The collections are working when the
classes are called directly, but not as a user control. Any advice is
appreciated.

Code:
------

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections;
namespace DropDownMenuControl
{
/// <summary>
/// Summary description for DropDownMenu.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:DropDownMenu runat=server></{0}:DropDownMenu>")]
public class DropDownMenu : System.Web.UI.WebControls.WebControl
{
private MenuList menuList = null;
private string text = string.Empty;

[
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
NotifyParentProperty(true)
]
public MenuList Menu
{
get
{
if(menuList == null)
{
menuList = new MenuList();
}
return menuList;

}
}

[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}

set
{
text = value;
}
}

/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
output.Write(Text);
}

}

public class MenuList
{

private MenuCategories categories = new MenuCategories();

public MenuList()
{
//
// TODO: Add constructor logic here
//
}

public MenuCategories MenuCategories
{
get
{
return categories;
}
set
{
categories = value;
}
}

public void AddCategory(MenuCategory menuCategory)
{
categories.AddCategory(menuCategory);
}

}
public class MenuCategories : IEnumerable
{

private ArrayList categories = new ArrayList();

public MenuCategories()
{
//
// TODO: Add constructor logic here
//
}

public int Count
{
get
{
return categories.Count;
}
}

public void AddCategory(MenuCategory category)
{
categories.Add(category);
}

public IEnumerator GetEnumerator()
{
return new MenuCategoriesEnumerator(categories);

}
}
public class MenuCategoriesEnumerator : IEnumerator
{

private ArrayList categories = new ArrayList();
private int position = -1;

public MenuCategoriesEnumerator(ArrayList categories)
{
this.categories = categories;
}

public object Current
{
get
{
return categories[position];

}
}

public bool MoveNext()
{
if (position < categories.Count - 1)
{
position ++;
return true;
}
else
{
return false;
}
}

public void Reset()
{
position = -1;
}

}
public class MenuCategory
{

private MenuCommands commands = new MenuCommands();
//private ArrayList categories = new ArrayList();

public MenuCategory()
{
//
// TODO: Add constructor logic here
//
}

public string HeaderText = string.Empty;
public string HeaderUrl = string.Empty;

public MenuCommands Commands
{
get
{
return commands;
}
set
{
commands = value;
}
}

public void AddCommand(MenuCommand menuCommand)
{
commands.AddCommand(menuCommand);
}

}

public class MenuCommands : IEnumerable
{

private ArrayList commands = new ArrayList();

public MenuCommands()
{
//
// TODO: Add constructor logic here
//
}

public int Count
{
get
{
return commands.Count;
}
}

public void AddCommand(MenuCommand menuCommand)
{
commands.Add(menuCommand);
}

public IEnumerator GetEnumerator()
{
return new MenuCommandsEnumerator(commands);

}
}
public class MenuCommandsEnumerator : IEnumerator
{

private ArrayList commands = new ArrayList();
private int position = -1;

public MenuCommandsEnumerator(ArrayList menuCommands)
{
commands = menuCommands;
}

public object Current
{
get
{
return commands[position];

}
}

public bool MoveNext()
{
if (position < commands.Count - 1)
{
position ++;
return true;
}
else
{
return false;
}
}

public void Reset()
{
position = -1;
}
}
public class MenuCommand
{

private string text = "";
private string url = "";

/// <summary>
/// Create a new menu command
/// </summary>
/// <param name="commandText">Text that is displayed in the menu
command</param>
/// <param name="commandUrl">The url that the menu command
launches</param>
public MenuCommand(string commandText, string commandUrl)
{
text = commandText;
url = commandUrl;
}

/// <summary>
/// Text that is displayed in the menu command
/// </summary>
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}

/// <summary>
/// The url that the menu command launches
/// </summary>
public string Url
{
get
{
return url;
}
set
{
url = value;
}
}
}

}
--
Jay Douglas
Fort Collins, CO


Nov 15 '05 #1
1 3143
I was creating the collection all wrong. I finally found my solution at:
http://groups.google.com/groups?hl=e...906a51a&rnum=3

--
Jay Douglas
Fort Collins, CO

"Jay Douglas" <ja******************@squarei.com> wrote in message
news:uq*************@tk2msftngp13.phx.gbl...
I need help getting the collections to show up in the property window of a
user control. I want to be able to edit the collection items just like any other asp.net control that has collection properties (i.e. The ASP:Table
control). This is for a menu system. The collections are working when the classes are called directly, but not as a user control. Any advice is
appreciated.

Code:
------

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections;
namespace DropDownMenuControl
{
/// <summary>
/// Summary description for DropDownMenu.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:DropDownMenu runat=server></{0}:DropDownMenu>")]
public class DropDownMenu : System.Web.UI.WebControls.WebControl
{
private MenuList menuList = null;
private string text = string.Empty;

[
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty),
NotifyParentProperty(true)
]
public MenuList Menu
{
get
{
if(menuList == null)
{
menuList = new MenuList();
}
return menuList;

}
}

[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}

set
{
text = value;
}
}

/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
output.Write(Text);
}

}

public class MenuList
{

private MenuCategories categories = new MenuCategories();

public MenuList()
{
//
// TODO: Add constructor logic here
//
}

public MenuCategories MenuCategories
{
get
{
return categories;
}
set
{
categories = value;
}
}

public void AddCategory(MenuCategory menuCategory)
{
categories.AddCategory(menuCategory);
}

}
public class MenuCategories : IEnumerable
{

private ArrayList categories = new ArrayList();

public MenuCategories()
{
//
// TODO: Add constructor logic here
//
}

public int Count
{
get
{
return categories.Count;
}
}

public void AddCategory(MenuCategory category)
{
categories.Add(category);
}

public IEnumerator GetEnumerator()
{
return new MenuCategoriesEnumerator(categories);

}
}
public class MenuCategoriesEnumerator : IEnumerator
{

private ArrayList categories = new ArrayList();
private int position = -1;

public MenuCategoriesEnumerator(ArrayList categories)
{
this.categories = categories;
}

public object Current
{
get
{
return categories[position];

}
}

public bool MoveNext()
{
if (position < categories.Count - 1)
{
position ++;
return true;
}
else
{
return false;
}
}

public void Reset()
{
position = -1;
}

}
public class MenuCategory
{

private MenuCommands commands = new MenuCommands();
//private ArrayList categories = new ArrayList();

public MenuCategory()
{
//
// TODO: Add constructor logic here
//
}

public string HeaderText = string.Empty;
public string HeaderUrl = string.Empty;

public MenuCommands Commands
{
get
{
return commands;
}
set
{
commands = value;
}
}

public void AddCommand(MenuCommand menuCommand)
{
commands.AddCommand(menuCommand);
}

}

public class MenuCommands : IEnumerable
{

private ArrayList commands = new ArrayList();

public MenuCommands()
{
//
// TODO: Add constructor logic here
//
}

public int Count
{
get
{
return commands.Count;
}
}

public void AddCommand(MenuCommand menuCommand)
{
commands.Add(menuCommand);
}

public IEnumerator GetEnumerator()
{
return new MenuCommandsEnumerator(commands);

}
}
public class MenuCommandsEnumerator : IEnumerator
{

private ArrayList commands = new ArrayList();
private int position = -1;

public MenuCommandsEnumerator(ArrayList menuCommands)
{
commands = menuCommands;
}

public object Current
{
get
{
return commands[position];

}
}

public bool MoveNext()
{
if (position < commands.Count - 1)
{
position ++;
return true;
}
else
{
return false;
}
}

public void Reset()
{
position = -1;
}
}
public class MenuCommand
{

private string text = "";
private string url = "";

/// <summary>
/// Create a new menu command
/// </summary>
/// <param name="commandText">Text that is displayed in the menu
command</param>
/// <param name="commandUrl">The url that the menu command
launches</param>
public MenuCommand(string commandText, string commandUrl)
{
text = commandText;
url = commandUrl;
}

/// <summary>
/// Text that is displayed in the menu command
/// </summary>
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}

/// <summary>
/// The url that the menu command launches
/// </summary>
public string Url
{
get
{
return url;
}
set
{
url = value;
}
}
}

}
--
Jay Douglas
Fort Collins, CO

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
2
by: Rob Richardson | last post by:
Greetings! I just developed a little control I've wanted for ages. It links a textbox and a label into a single control. At first, I gave it a property named LabelText and another named...
1
by: Jay Douglas | last post by:
I need help getting the collections to show up in the property window of a user control. I want to be able to edit the collection items just like any other asp.net control that has collection...
0
by: Tom | last post by:
I am having a really annoying issue with serialization and a .NET User Control I am writing. For example, let's say I have a couple of classes in my control - first class is like: Public Class...
4
by: Michael | last post by:
Dear all .. If I want to use develop a user control and declare a public property which the type is System.Windows.Forms.GridTableStylesCollection For example : Public Class LookAndView...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
1
by: abyclassic | last post by:
Dear All, I am making a Windows Control Library(user control) using VS.NET & C#.NET. Now, i am facing 3 problems: 1.In this control, i wants to remove some of the properties which are available...
0
by: DigitalDan3 | last post by:
Visual Studio 2008 C#. Web Controls I have a simple user control (TextBoxViewer) that contains 2 controls a TextBox and a Label Control. The usercontrol exposes a default "Text" property and also...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.