Click here to Skip to main content
15,305,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form with many controls such as textbox, combobox, checkbox and etc.
User can fill them or let them empty and then press Filter button.
What are the solutions, is it possible to do it with LINQ?

It is possible to use LINQ in principle, but hardly makes much sense. Controls are organized in parent-child relationships in one single hierarchy, so you will need to search it recursively using the property System.Windows.Forms.Control.Controls. This is simple, but what's your search criteria?

I would note though that the necessity of such search is a good sign of really bad UI design. Correct design never needs such search.

The basic idea is: you need to have a data layer isolated from UI; you will need data binding or population of of the UI with the data, update of the data based on UI. (A hint: think "Controller".)

I suggest you learn and analyze applicability of the following architectural patterns ([^]):

MVVM — Model View View Model,[^],

MVC — Model-View-Controller,[^]),

MVA — Model-View-Adapter,–view–adapter[^],

MVP — Model-View-Presenter,[^].
Pay attention for the motivation of those architectures. If you understand it, you would be able to create better design ideas.

Mehdi Gholam 16-Nov-11 3:55am
Expertly said, 5!
Thank you, Mehdi. After all they call us experts, should we be adequate to it or not? :-)
Hamid Noahdi 16-Nov-11 4:00am
Thanks for answer, what you say about architectural patternsis completely right, but i need a solution for advanced filter, for example sometimes user need to filter a persons name, sometimes name and family or many other options like sex, age, born date and etc.
Yes it is very much possible using LINQ, and simple too!!! :)

follow the link to learn in detail.[^][^][^]

mark as answer if solves your problem, it motivates :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900