如何使用coolite 控件工具包在手风琴内动态添加带有菜单项的菜单面板。
问问题
323 次
1 回答
1
你可以在这里试试我的样品:
private void CreateMenu(int index, string title, string url, MenuPanel menuPanel, Panel panel)
{
MenuItem menuItem = new MenuItem();
menuItem.ID = "MenuItem" + index;
menuItem.Text = title;
menuItem.Listeners.Click.Handler += "addTab(#{TabPanel1},#{" + menuPanel.ID + "},'MenuItem" + index + "',' " + title + "',' " + url + "');";
menuItem.Icon = Icon.ApplicationForm;
menuPanel.Menu.Items.Add(menuItem);
panel.BodyControls.Add(menuPanel);
Accordion1.Items.Add(panel);
}
private void PopulateMenus()
{
string[] menus = new string[] { null, "Menu 1", null, "Menu 2"};
MenuPanel menuPanel = null;
Panel panel = null;
for (int i = 0; i < menus.Length; i++)
{
if (menus[i] == null)
{
panel = new Panel();
panel.AutoScroll = true;
panel.ID = "Menu" + i;
panel.Title = menus[i + 1];
panel.Border = false;
panel.BodyStyle = "padding:6px;";
panel.Icon = Icon.ApplicationCascade;
menuPanel = new MenuPanel();
menuPanel.AutoScroll = true;
menuPanel.ID = "MenuPanel" + i;
menuPanel.Border = false;
menuPanel.BodyStyle = "padding:6px;";
continue;
}
CreateMenu(i, "Sub-" + menus[i], "www.test.com", menuPanel, panel);
}
}
希望能帮助到你。
于 2011-01-10T09:36:05.203 回答