System.Windows.Forms.Control.ControlCollection.Find(string, bool)

Here are the examples of the csharp api class System.Windows.Forms.Control.ControlCollection.Find(string, bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

34 Examples 7

1. Example

Project: XrmToolBox
Source File: PluginControlBase.cs
View license
protected void ShowInfoNotification(string message, Uri moreInfoUri, int height = 32)
        {
            var ctrls = Parent.Controls.Find("NotifPanel", false);
            if (ctrls.Length == 1)
            {
                ((NotificationArea)ctrls[0]).ShowInfoNotification(message, moreInfoUri, height);
            }
            else
            {
                throw new Exception("Unable to find Notification Area control");
            }
        }

2. Example

Project: XrmToolBox
Source File: PluginControlBase.cs
View license
protected void ShowWarningNotification(string message, Uri moreInfoUri, int height = 32)
        {
            var ctrls = Parent.Controls.Find("NotifPanel", false);
            if (ctrls.Length == 1)
            {
                ((NotificationArea)ctrls[0]).ShowWarningNotification(message, moreInfoUri, height);
            }
            else
            {
                throw new Exception("Unable to find Notification Area control");
            }
        }

3. Example

Project: XrmToolBox
Source File: PluginControlBase.cs
View license
protected void ShowErrorNotification(string message, Uri moreInfoUri, int height = 32)
        {
            var ctrls = Parent.Controls.Find("NotifPanel", false);
            if (ctrls.Length == 1)
            {
                ((NotificationArea)ctrls[0]).ShowErrorNotification(message, moreInfoUri, height);
            }
            else
            {
                throw new Exception("Unable to find Notification Area control");
            }
        }

4. Example

Project: XrmToolBox
Source File: PluginControlBase.cs
View license
protected void HideNotification()
        {
            var ctrls = Parent.Controls.Find("NotifPanel", false);
            if (ctrls.Length == 1)
            {
                ctrls[0].Visible = false;
            }
        }

5. Example

Project: hakchi2
Source File: ImagesForm.cs
View license
public void ShowImages(IEnumerable<Image> images)
        {
            int i = 0;
            Control[] pboxes;
            do
            {
                i++;
                pboxes = this.Controls.Find("pictureBox" + i, true);
                if (pboxes.Length > 0)
                {
                    (pboxes[0] as PictureBox).Image = null;
                    (pboxes[0] as PictureBox).Visible = false;
                }
            } while (pboxes.Length > 0);
            i = 0;
            foreach(var image in images)
            {
                i++;
                pboxes = this.Controls.Find("pictureBox"+i, true);
                if (pboxes.Length > 0)
                {
                    (pboxes[0] as PictureBox).Image = image;
                    (pboxes[0] as PictureBox).Visible = true;
                }
            }
        }

6. Example

Project: ExpressionBuilder
Source File: ucFilter.cs
View license
private void SetControlVisibility(string controlName, bool visible)
        {
            var ctrl = Controls.Find(controlName, false).FirstOrDefault();
            
            if (ctrl != null)
            {
                ctrl.Visible = visible;
            }
        }

7. Example

Project: DotSpatial
Source File: CustomHeaderControl.cs
View license
private Control GetItem(string key)
        {
            var item = _container.Controls.Find(key, true).FirstOrDefault();
            return item;
        }

8. Example

Project: Mario-Game
Source File: FormParams.cs
View license
private void bSave_Click(object sender, EventArgs e)
        {

            for (int i = 0; i < 3; i++)
            {
                ComboBox C = (ComboBox)Controls.Find("cInt" + (i + 1), false)[0];
                if (C.Visible)
                    MainObject.ParamInt[i] = intValues[i][C.SelectedIndex];

                C = (ComboBox)Controls.Find("cBool" + (i + 1), false)[0];
                if (C.Visible)
                {
                    if (C.SelectedIndex == 0)
                        MainObject.Parambool[i] = true;
                    else
                        MainObject.Parambool[i] = false;

                }

            }
            
            Update = true;
            Close();
        }

9. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void RemoveAllItems(object sender, EventArgs e)
        {
            // Get Current Pouch
            int pouch = CurrentPouch;
            if (pouch < 0)
                return;

            DataGridView dgv = Controls.Find(DGVPrefix + Pouches[pouch].Type, true).FirstOrDefault() as DataGridView;
            
            for (int i = 0; i < dgv.RowCount; i++)
            {
                int c = 0;
                dgv.Rows[i].Cells[c++].Value = itemlist[0];
                dgv.Rows[i].Cells[c++].Value = 0;
                if (HasFreeSpace)
                    dgv.Rows[i].Cells[c++].Value = false;
                if (HasNew)
                    dgv.Rows[i].Cells[c].Value = false;
            }
            WinFormsUtil.Alert("Items cleared.");
        }

10. Example

Project: synthesis
Source File: PropertySetsTabControl.cs
View license
private void PropertySetsTabControl_Deselecting(object sender, TabControlCancelEventArgs e)
        {
            if (e.TabPage != null)
            {
                Control[] controlCollection = SelectedTab.Controls.Find("ComponentPropertiesForm", false);

                if (controlCollection.Length > 0)
                {
                    ComponentPropertiesForm form = (ComponentPropertiesForm)controlCollection[0];
                    if (form != null)
                    {
                        if (form.InteractionEnabled)
                        {
                            e.Cancel = true;
                            MessageBox.Show("Please exit select mode before changing or adding tabs.", "Invalid operation.");
                        }
                    }
                }
            }
        }

11. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void SetBags()
        {
            foreach (InventoryPouch t in Pouches)
            {
                DataGridView dgv = Controls.Find(DGVPrefix + t.Type, true).FirstOrDefault() as DataGridView;
                SetBag(dgv, t);
            }
        }

12. Example

Project: PokemonGo-Bot
Source File: ItemsPanel.cs
View license
void btnCopy_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvitem in ItemsListView.Items) {
                var item = (ItemData)(lvitem.Tag);
                var controlName = item.ItemId.ToString();
                controlName = controlName.Replace("Item", "num_Max") + "s";
                var controls = Controls.Find(controlName, true);
                if (controls.Length > 0) {
                    ((NumericUpDown)controls[0]).Value = item.Count;
                }
            }
        }

13. Example

View license
public void SetCustomFilter ()
    {

      int Max = this.CustomFilter.GetSize();
      
      for( int Slot = 0 ; Slot < Max ; Slot++ )
      {
      
        ComboBox ComboBoxFilter;
        TextBox TextBoxFilter;

        ComboBoxFilter = this.Controls.Find(
          string.Format( "ComboBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as ComboBox;

        TextBoxFilter = this.Controls.Find(
          string.Format( "TextBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as TextBox;

        if( this.CustomFilter.IsEnabled() )
        {

          KeyValuePair<string,?MacroscopeConstants.Contains> Pair = this.CustomFilter.GetPattern( Slot: Slot );

          switch( Pair.Value )
          {

            case MacroscopeConstants.Contains.MUSTHAVE:
              ComboBoxFilter.SelectedIndex = 1;
              break;

            case MacroscopeConstants.Contains.MUSTNOTHAVE:
              ComboBoxFilter.SelectedIndex = 2;
              break;

            default:
              ComboBoxFilter.SelectedIndex = 0;
              break;

          }

          TextBoxFilter.Text = Pair.Key;

        }
        else
        {
        
          ComboBoxFilter.SelectedIndex = 0;
          TextBoxFilter.Text = "";

        }

      }
     
    }

14. Example

View license
public MacroscopeCustomFilters GetCustomFilter ()
    {

      int Max = this.CustomFilter.GetSize();
      
      for( int Slot = 0 ; Slot < Max ; Slot++ )
      {
      
        ComboBox ComboBoxFilter;
        TextBox TextBoxFilter;

        ComboBoxFilter = this.Controls.Find(
          string.Format( "ComboBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as ComboBox;

        TextBoxFilter = this.Controls.Find(
          string.Format( "TextBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as TextBox;

        switch( ComboBoxFilter.SelectedIndex )
        {

          case 1:
            this.CustomFilter.SetPattern(
              Slot: Slot, 
              Text: TextBoxFilter.Text, 
              ContainsSetting: MacroscopeConstants.Contains.MUSTHAVE
            );
            break;

          case 2:
            this.CustomFilter.SetPattern(
              Slot: Slot, 
              Text: TextBoxFilter.Text, 
              ContainsSetting: MacroscopeConstants.Contains.MUSTNOTHAVE
            );
            break;

          default:
            this.CustomFilter.SetPattern(
              Slot: Slot, 
              Text: "", 
              ContainsSetting: MacroscopeConstants.Contains.UNDEFINED
            );
            break;

        }

      }

      return( this.CustomFilter );

    }

15. Example

Project: 3DSRNGTool
Source File: TinyTimelineTool.cs
View license
private void TypeNum_ValueChanged(object sender, EventArgs e)
        {
            for (int i = 1; i <= TypeNum.Maximum; i++)
            {
                Controls.Find("Frame" + i.ToString(), true).FirstOrDefault().Enabled = i <= TypeNum.Value;
                Controls.Find("Type" + i.ToString(), true).FirstOrDefault().Enabled = i <= TypeNum.Value;
            }
        }

16. Example

Project: SceneNavi
Source File: MainForm.cs
View license
private void SelectActorNumberControl(TableLayoutPanel tlp)
        {
            Control ctrl = tlp.Controls.Find("ActorNumber", false).FirstOrDefault();
            if (ctrl != null && ctrl is TextBox)
            {
                TextBox txt = (ctrl as TextBox);
                txt.SelectionStart = txt.Text.Length;
                txt.Select();
            }
        }

17. Example

Project: Mario-Game
Source File: FormParams.cs
View license
public void LoadParams()
        {
            object[] intS = (object[])MainObject.ParamTypes[0];
 /n ..... /n //View Source file for more details /n }

18. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void GetBags()
        {
            foreach (InventoryPouch pouch in Pouches)
            {
                DataGridView dgv = Controls.Find(DGVPrefix + pouch.Type, true).FirstOrDefault() as DataGridView;

                // Sanity Screen
                var invalid = pouch.Items.Where(item => item.Index != 0 && !pouch.LegalItems.Contains((ushort)item.Index)).ToArray();
                var outOfBounds = invalid.Where(item => item.Index >= itemlist.Length).ToArray();
                var incorrectPouch = invalid.Where(item => item.Index < itemlist.Length).ToArray();

                if (outOfBounds.Any())
                    WinFormsUtil.Error("Unknown item detected.",
                        $"Item ID(s): {string.Join(", ", outOfBounds.Select(item => item.Index))}");
                if (!Main.HaX && incorrectPouch.Any())
                    WinFormsUtil.Alert($"The following item(s) have been removed from {pouch.Type} pouch.",
                        string.Join(", ", incorrectPouch.Select(item => itemlist[item.Index])), 
                        "If you save changes, the item(s) will no longer be in the pouch.");

                pouch.Sanitize(Main.HaX, itemlist.Length - 1);
                GetBag(dgv, pouch);
            }
        }

19. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void SortByName(object sender, EventArgs e)
        {
            int pouch = CurrentPouch;
            var dgv = Controls.Find(DGVPrefix + Pouches[pouch].Type, true).FirstOrDefault() as DataGridView;
            var p = Pouches[pouch];
            SetBag(dgv, p);
            if (sender == mnuSortName)
                p.SortByName(itemlist, reverse:false);
            if (sender == mnuSortNameReverse)
                p.SortByName(itemlist, reverse:true);
            GetBag(dgv, p);
        }

20. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void SortByCount(object sender, EventArgs e)
        {
            int pouch = CurrentPouch;
            var dgv = Controls.Find(DGVPrefix + Pouches[pouch].Type, true).FirstOrDefault() as DataGridView;
            var p = Pouches[pouch];
            SetBag(dgv, p);
            if (sender == mnuSortCount)
                p.SortByCount(reverse:false);
            if (sender == mnuSortCountReverse)
                p.SortByCount(reverse:true);
            GetBag(dgv, p);
        }

21. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void SortByIndex(object sender, EventArgs e)
        {
            int pouch = CurrentPouch;
            var dgv = Controls.Find(DGVPrefix + Pouches[pouch].Type, true).FirstOrDefault() as DataGridView;
            var p = Pouches[pouch];
            SetBag(dgv, p);
            if (sender == mnuSortIndex)
                p.SortByIndex(reverse: false);
            if (sender == mnuSortIndexReverse)
                p.SortByIndex(reverse: true);
            GetBag(dgv, p);
        }

22. Example

View license
public Boolean ValidateForm ( Boolean ShowErrorDialogue )
    {

      Boolean IsValid = true;
      int Max = this.CustomFilter.GetSize();

      for( int Slot = 0 ; Slot < Max ; Slot++ )
      {

        ComboBox ComboBoxFilter;
        TextBox TextBoxFilter;

        ComboBoxFilter = this.Controls.Find(
          string.Format( "ComboBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as ComboBox;

        TextBoxFilter = this.Controls.Find(
          string.Format( "TextBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as TextBox;

        switch( ComboBoxFilter.SelectedIndex )
        {

          case 1:
            if(
              !this.ValidateExpression(
                TextBoxObject: TextBoxFilter, 
                ShowErrorDialogue: ShowErrorDialogue 
              ) )
            {
              IsValid = false;
            }
            break;

          case 2:
            if(
              !this.ValidateExpression(
                TextBoxObject: TextBoxFilter, 
                ShowErrorDialogue: ShowErrorDialogue 
              ) )
            {
              IsValid = false;
            }
            break;

          default:
            break;

        }

        if( !IsValid )
        {
          break;
        }
                
      }

      return( IsValid );

    }

23. Example

View license
public void ClearCustomFilterForm ()
    {

      int Max = this.CustomFilter.GetSize();
      
      this.SetEnableValidation( State: false );
            
      for( int Slot = 0 ; Slot < Max ; Slot++ )
      {
      
        TextBox TextBoxFilter;
        ComboBox ComboBoxFilter;
          
        TextBoxFilter = this.Controls.Find(
          string.Format( "TextBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as TextBox;
          
        ComboBoxFilter = this.Controls.Find(
          string.Format( "ComboBoxFilter{0}", Slot + 1 ),
          true
        ).FirstOrDefault() as ComboBox;

        ComboBoxFilter.SelectedIndex = 0;
        TextBoxFilter.Text = "";

      }

      this.SetEnableValidation( State: true );
            
    }

24. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void ModifyAllItems(object sender, EventArgs e)
        {
            // Get Current Pouch
            int pouch = CurrentPouch;
            if (pouch < 0)
                return;

            DataGridView dgv = Controls.Find(DGVPrefix + Pouches[pouch].Type, true).FirstOrDefault() as DataGridView;

            for (int i = 0; i < dgv.RowCount; i++)
            {
                string item = dgv.Rows[i].Cells[0].Value.ToString();
                int itemindex = Array.IndexOf(itemlist, item);
                if (itemindex > 0)
                    dgv.Rows[i].Cells[1].Value = IsItemCount1((ushort)itemindex, SAV) ? 1 : NUD_Count.Value;

            }
            WinFormsUtil.Alert("Item count modified.");
        }

25. Example

Project: PKHeX
Source File: SAV_Inventory.cs
View license
private void GiveAllItems(object sender, EventArgs e)
        {
            // Get Current Pouch
   /n ..... /n //View Source file for more details /n }

26. Example

Project: PokemonSunMoonRNGTool
Source File: FormUtil.cs
View license
private static object FindControl(string name, Control.ControlCollection c)
        {
            Control control = c.Find(name, true).FirstOrDefault();
            if (control != null)
                return control;
            foreach (MenuStrip menu in c.OfType<MenuStrip>())
            {
                var item = menu.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                    return item;
            }
            foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType<Control>()))
            {
                var item = strip.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                    return item;
            }
            foreach (DataGridView dg in c.OfType<DataGridView>())
            {
                foreach (var col in dg.Columns.OfType<DataGridViewColumn>())
                    if (col.Name == name)
                        return col;
            }
            foreach (Control x in c)
            {
                var z = FindControl(name, x.Controls);
                if (z != null)
                    return z;
            }
            return null;
        }

27. Example

Project: SPDG
Source File: ucSteps.cs
View license
public void showStep(int stepNumber)
        {
            foreach (Control ctrl in this.Controls)
            {
                if (ctrl.Name.StartsWith("lblStep"))
                {
                    int lblNumber = Convert.ToInt32(ctrl.Name.Replace("lblStep", "").TrimStart('0'));
                    if (lblNumber <= stepNumber)
                    {                     
                        bool canBeEnabled = !_serverSteps.Contains(lblNumber) || !Common.WorkingDefinition.IsClientObjectModel;
                        if (canBeEnabled)
                        {
                            ctrl.Enabled = true;
                            ((LinkLabel) ctrl).Links[0].Enabled = true;
                            Control[] ctrls = this.Controls.Find("pictureBox" + lblNumber, false);
                            if (ctrls.Length > 0)
                            {
                                ((PictureBox) ctrls[0]).Image = Resources.temp_icona_12;
                            }
                        }
                    }
                }
            }


        }

28. Example

Project: SMEncounterRNGTool
Source File: FormUtil.cs
View license
private static object FindControl(string name, Control.ControlCollection c)
        {
            Control control = c.Find(name, true).FirstOrDefault();
            if (control != null)
                return control;
            foreach (MenuStrip menu in c.OfType<MenuStrip>())
            {
                var item = menu.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                    return item;
            }
            foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType<Control>()))
            {
                var item = strip.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                    return item;
            }
            foreach (DataGridView dg in c.OfType<DataGridView>())
            {
                foreach (var col in dg.Columns.OfType<DataGridViewColumn>())
                    if (col.Name == name)
                        return col;
            }
            foreach (Control x in c)
            {
                var z = FindControl(name, x.Controls);
                if (z != null)
                    return z;
            }
            return null;
        }

29. Example

Project: 3DSRNGTool
Source File: FormUtil.cs
View license
private static object FindControl(string name, Control.ControlCollection c)
        {
            Control control = c.Find(name, true).FirstOrDefault();
            if (control != null)
                return control;
            foreach (MenuStrip menu in c.OfType<MenuStrip>())
            {
                var item = menu.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                    return item;
            }
            foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType<Control>()))
            {
                var item = strip.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                    return item;
            }
            foreach (DataGridView dg in c.OfType<DataGridView>())
            {
                foreach (var col in dg.Columns.OfType<DataGridViewColumn>())
                    if (col.Name == name)
                        return col;
            }
            foreach (Control x in c)
            {
                var z = FindControl(name, x.Controls);
                if (z != null)
                    return z;
            }
            return null;
        }

30. Example

Project: ScpToolkit
Source File: ListViewAppender.cs
View license
protected override void Append(LoggingEvent loggingEvent)
        {
            if (_listView == nul/n ..... /n //View Source file for more details /n }

31. Example

Project: nfx-demos
Source File: Shell.cs
View license
private void loadConfigurationsAndInfos()
        {
            var textBoxes = App.ConfigRoot[TEXT_BOXES_NODE];
            if (textBoxes == null)
                return;

            foreach (var tb in textBoxes.Children)
            {
                var controlName = tb.AttrByName(TEXT_BOX_ATTR_NAME).Value;
                var path = tb.AttrByName(TEXT_BOX_ATTR_PATH).Value;
                var isRTF = tb.AttrByName(TEXT_BOX_ATTR_RTF).ValueAsBool();

                var searchResult = this.Controls.Find(controlName, true);
                if (searchResult.Count() == 0)
                    continue;
                var textBox = searchResult[0] as RichTextBox;

                try
                {
                    if (isRTF)
                    {
                        var txt = File.ReadAllText(path);
                        textBox.Rtf = txt;
                    }
                    else
                        textBox.LoadFile(path, RichTextBoxStreamType.PlainText);
                }
                catch (Exception e)
                {
                    textBox.Text = e.ToMessageWithType();
                }
            }
        }

32. Example

Project: 3DSRNGTool
Source File: TinyTimelineTool.cs
View license
public void Calibrate(int type, int Curr, int Next)
        {
            if (SkipList.Count == TypeNum.Value || type < 0 || type > 3)    // All used
            {
                B_Stop_Click(null, null);
                return;
            }
            if (SkipList.IndexOf(Curr) > -1) // Skip
                SkipList[SkipList.IndexOf(Curr)] = Next;
            else
            {
                SkipList.Add(Next);
                ((NumericUpDown)Controls.Find("Frame" + SkipList.Count.ToString(), true).FirstOrDefault()).Value = Curr;
                ((ComboBox)Controls.Find("Type" + SkipList.Count.ToString(), true).FirstOrDefault()).SelectedValue = type;
                B_Create_Click(null, null);
            }
            return;
        }

33. Example

Project: IRCBot
Source File: Interface.cs
View license
private void add_tab(string tab_name)
        {
            if (tabControl1.InvokeRequired)
        /n ..... /n //View Source file for more details /n }

34. Example

Project: MGE-XE
Source File: LocalizationInterface.cs
View license
public void Apply (Form form, Localization localization) {
            FieldInfo messages_field;
   /n ..... /n //View Source file for more details /n }