WinForm程序设计-工具栏(ToolBar)和图象列表控件(ImageList)
2008-05-10 08:45:41
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://chenxing.blog.51cto.com/240526/76280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
一、在表单上放置一个工具栏控件ID为tool,一个图象列表控件,ID为image,为图象列表控件添加几个图片
二、将工具栏控件的ImageList属性设置为图象列表控件的ID值,打开工具栏控件的Buttons集合,为工具栏添加几个按钮. 三、从数据库中提取系统功能清单并动态将功能ID与工具栏按纽绑定
con=new SqlConnection(@ConfigurationSettings.AppSettings["server"]); con.Open(); da=new SqlDataAdapter("select mkmc,enabled,akey from userqxb where userid='"+tool.Tag.ToString()+"' and bkey='0_'",con); ds=new DataSet(); da.Fill (ds,“userqxb”);//将装有功能的表取入内存数据集中 con.Close (); for(int i=0;i<ds.Tables ["userqxb"].Rows .Count;i++ ) { for(int j=0;j<tool.Buttons.Count;j++) { if(tool.Buttons[j].Text==ds.Tables ["userqxb"].Rows [i][0].ToString ()) { tool.Buttons[j].Visible=Convert.ToBoolean(ds.Tables ["userqxb"].Rows [i][1].ToString ()); tool.Buttons[j].Tag=ds.Tables ["userqxb"].Rows [i][2].ToString (); break; } } } ![]() 系统所需要用到的数据原表结构如下
本文出自 “半瓶香油-好男人时来运转” 博客,请务必保留此出处http://chenxing.blog.51cto.com/240526/76280 本文出自 51CTO.COM技术博客 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||



晨星
博客统计信息
热门文章
最新评论
友情链接

