在toolbar里动态创建多个button(ext.net)
private void setOneMenu() { string sql = "select id,name,gids from Config where name<>'高级设置' and name<>'基础设置' order by [Order] desc"; DataTable dt = Sunway.DBUtility.DbHelperSQL.ExecuteDataSet(CommandType.Text, sql, null).Tables[0]; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Ext.Net.Button but = new Ext.Net.Button();//动态button Ext.Net.ToolbarSeparator toolBarS = new ToolbarSeparator();//动态button but.Text =dr["name"].ToString();//给button进行赋值 but.StandOut = false;//点击凹出 but.Icon = Icon.ApplicationCascade;//图标 but.Listeners.Click.Handler = @"setTow(" + dr["id"].ToString() + ")";//定义事件。//but.ToolTip=//鼠标放上浮框信息 toolBar.Items.Add(but);//toolBar载入button toolBar.Items.Add(toolBarS);//toolBar载入ToolbarSeparator } } }