473,386 Members | 1,734 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,386 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 17 '05 #1
1 1322
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 17 '05 #2

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

Similar topics

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...
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...
1
by: Steven.Xu | last post by:
Hi, everyone. I am writting an user control. There has some properties on it. At the design time, the properties will disply on the property windows and user could change it's value after selected...
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.