飞道的博客

C#之DotNetBar2使用方法 - itemPanel1

587人阅读  评论(0)

itemPanel做个按钮菜单,模拟用来操控开关按钮

   

对象buttonItem1的属性(itempanel可以添加的子控件列表对象,根据需要选择,这里用到的Button)

可以用控件自带的样式,也可以用代码控制,也可以预先设置好。(图标,颜色,大小)

c#代码使用 修改symbol的方法:button.Symbol = "\uf060"; (VB:button.Symbol = ChrW("&Hf060"))代码如下

批量对象buttonitem添加(动态添加按钮的方法)


  
  1. int itemcount = 8; //添加按钮的个数
  2. Random rd = new Random();
  3. itemPanel1.Items.Clear(); //先清后添加
  4. for ( int i = 0; i < itemcount; i++)
  5. {
  6. Button button = null;
  7. button = new Button ();
  8. ControlContainerItem containerItem = new ControlContainerItem();
  9. containerItem.Control = button;
  10. containerItem.Text= "通道"+(i+ 1);
  11. //可以设置其他属性 大小 文本 居中方式等
  12. }
  13. //为每个按钮创建点击事件即可操作

 

 


转载:https://blog.csdn.net/uaime/article/details/116403283
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场