System.Windows.Forms.ToolStripManager.FindToolStrip C# (CSharp) Method

FindToolStrip() public static method

public static FindToolStrip ( string toolStripName ) : ToolStrip
toolStripName string
return ToolStrip
		public static ToolStrip FindToolStrip (string toolStripName)
		{
			lock (toolstrips)
				foreach (WeakReference wr in toolstrips) {
					ToolStrip ts = (ToolStrip)wr.Target;
					
					if (ts == null)
						continue;
				
					if (ts.Name == toolStripName)
						return ts;
				}
						
			return null;
		}
		

Usage Example

Example #1
0
 private void ApplySettings(ArrayList toolStripSettingsToApply)
 {
     if (toolStripSettingsToApply.Count != 0)
     {
         this.SuspendAllLayout(this.form);
         Dictionary <string, ToolStrip>            itemLocationHash = this.BuildItemOriginationHash();
         Dictionary <object, List <SettingsStub> > dictionary2      = new Dictionary <object, List <SettingsStub> >();
         foreach (SettingsStub stub in toolStripSettingsToApply)
         {
             object key = !string.IsNullOrEmpty(stub.ToolStripPanelName) ? stub.ToolStripPanelName : null;
             if (key == null)
             {
                 if (!string.IsNullOrEmpty(stub.Name))
                 {
                     ToolStrip toolStrip = ToolStripManager.FindToolStrip(this.form, stub.Name);
                     this.ApplyToolStripSettings(toolStrip, stub, itemLocationHash);
                 }
             }
             else
             {
                 if (!dictionary2.ContainsKey(key))
                 {
                     dictionary2[key] = new List <SettingsStub>();
                 }
                 dictionary2[key].Add(stub);
             }
         }
         foreach (ToolStripPanel panel in this.FindToolStripPanels(true, this.form.Controls))
         {
             foreach (Control control in panel.Controls)
             {
                 control.Visible = false;
             }
             string name = panel.Name;
             if ((string.IsNullOrEmpty(name) && (panel.Parent is ToolStripContainer)) && !string.IsNullOrEmpty(panel.Parent.Name))
             {
                 name = panel.Parent.Name + "." + panel.Dock.ToString();
             }
             panel.BeginInit();
             if (dictionary2.ContainsKey(name))
             {
                 List <SettingsStub> list2 = dictionary2[name];
                 if (list2 != null)
                 {
                     foreach (SettingsStub stub2 in list2)
                     {
                         if (!string.IsNullOrEmpty(stub2.Name))
                         {
                             ToolStrip strip2 = ToolStripManager.FindToolStrip(this.form, stub2.Name);
                             this.ApplyToolStripSettings(strip2, stub2, itemLocationHash);
                             panel.Join(strip2, stub2.Location);
                         }
                     }
                 }
             }
             panel.EndInit();
         }
         this.ResumeAllLayout(this.form, true);
     }
 }
All Usage Examples Of System.Windows.Forms.ToolStripManager::FindToolStrip