0

I am currently working on a search box that find components. Example you type Save Client and it will then filter out all other components (Set their visibility to false) and only show the Save client button. I currently have over 60 odd buttons and other components labels, comboboxes etc. I am stuck big time and have no idea on how to achieve this feature. I have looked into Find Controls but the findings wasn't what I am looking for. Thanks for your help in advance.

  • Do you know how to get all controls on your form? If yes, then that's half of your feature. The other half is to decide which properties to inspect during search. A naive approach would just check the type of control and then (e. g. for a `Label`) look in the `.Text` property. – germi Dec 12 '19 at 08:51
  • Thanks for the fast response, I was thinking about doing something like this: `private Control FindControl(Control parent, string name) { if (parent.Name == name) return parent; foreach (Control ctl in parent.Controls) { Control found = FindControl(ctl, name); if (found != null) return found; } return null; }` – AspectCoders Dec 12 '19 at 08:54
  • Take [this](https://stackoverflow.com/a/3426721/11683) and replace the `.Where(c => c.GetType() == type)` with `.Where(c => c.Name == name)`. – GSerg Dec 12 '19 at 09:01
  • Thank you, with this I have something I can work with and a step in the right direction. – AspectCoders Dec 12 '19 at 09:19

0 Answers0