toolBarButton.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
这种风格的按钮就是分隔线了
至于图标,先建一个ImageList,
然后设定toolBar.ImageList = ImageList_Name;
指定:
toolBarButton?.ImageIndex = ?;声明:以上代码都可以通过VS可视设计自动生成

解决方案 »

  1.   

    在ToolBar里面写了一个
    但是点击不同的按钮都是一样的事件
    要怎么区分不同的按钮呢
      

  2.   

    根据参数e的button属性判断。protected void toolBar1_ButtonClick (
                             Object sender, 
                             ToolBarButtonClickEventArgs e)
     {   switch(toolBar1.Buttons.IndexOf(e.Button))
       {
          case 0:
             openFileDialog1.ShowDialog();
             // Insert code to open the file.
             break; 
          case 1:
             saveFileDialog1.ShowDialog();
             // Insert code to save the file.
             break; 
          case 2:
             printDialog1.ShowDialog();
             // Insert code to print the file.    
             break; 
        }
     }
      

  3.   

    用Index不是最好的,如果修改了顺序则需要修改代码
    一般使用
    if (e.Button.Equals(按钮对象)){//}
      

  4.   

    如果工具栏按钮有文本,也可以用它的文本区分:
            private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
            {
                switch (e.Button.Text)
                {
                    case "增加":
                        .....
                        break;
                    case "修改":
                        .....
                        break;
    .....
                }
            }