示例#1
0
 /// <summary>
 /// 添加一项到列表中
 /// </summary>
 /// <param name="text"></param>
 public void AddItem(string text, bool ischecked = false)
 {
     try
     {
         //添加到ToolStripDropDown的Items中
         //将ComboBox列表中的项添加到ToolStripDropDown的Items中
         if (myToolStripDropDown != null)
         {
             myToolStripDropDown.AutoSize = true;
             myToolStripButton dropDownItem = new myToolStripButton(text);
             dropDownItem.AutoSize   = false;
             dropDownItem.Image      = Resources.icon_normal;
             dropDownItem.ImageAlign = ContentAlignment.MiddleLeft;
             dropDownItem.TextAlign  = ContentAlignment.MiddleLeft;
             dropDownItem.Size       = new Size(this.pnlTopParent.Width, 32);
             //插入项"清空地址栏下列表"之前
             if (ischecked)
             {
                 if (PressedItem != null)
                 {
                     PressedItem.IsSelected = false;
                 }
                 dropDownItem.IsSelected = true;
                 PressedItem             = dropDownItem;
             }
             myToolStripDropDown.Items.Insert(myToolStripDropDown.Items.Count - 1, dropDownItem);
             myToolStripDropDown.Update();
             //myToolStripDropDown.Items.Add(dropDownItem);
         }
     }
     catch (Exception ex)
     {
         //Win32API.OutputDebugStringA(string.Format("添加时遇到错误:{0}",ex.Message));
     }
 }
示例#2
0
 private void button2_Click(object sender, EventArgs e)
 {
     //this.addressBox1.Text="https://bing.com.cn";
     //this.addressBox1.UrlTitle = "必应";
     try
     {
         //添加到ToolStripDropDown的Items中
         //将ComboBox列表中的项添加到ToolStripDropDown的Items中
         if (myToolStripDropDown != null)
         {
             myToolStripDropDown.AutoSize = true;
             myDownloadToolStrip dropDownItem = new myDownloadToolStrip("铁呀呀的牙");
             dropDownItem.AutoSize           = false;
             dropDownItem.DownloadSpeed      = "大小:81.93MB - 8.14MB/s";
             dropDownItem.ProgressPercentage = 85;
             dropDownItem.Image      = Resources.mnudownload;
             dropDownItem.ImageAlign = ContentAlignment.MiddleLeft;
             dropDownItem.TextAlign  = ContentAlignment.MiddleLeft;
             dropDownItem.Size       = new Size(this.panel1.Width, 60);
             //插入项"清空地址栏下列表"之前
             //myToolStripDropDown.Items.Insert(myToolStripDropDown.Items.Count, dropDownItem);
             myToolStripDropDown.Items.Add(dropDownItem);
             myToolStripDropDown.Update();
             //myToolStripDropDown.Items.Add(dropDownItem);
         }
     }
     catch (Exception ex)
     {
         //Win32API.OutputDebugStringA(string.Format("添加时遇到错误:{0}",ex.Message));
     }
 }