I'm creating a search form in my WindowsForm application:
public partial class SearchForm<T>()
{
....
}
i want in run-time create some Controls based on T
property types,
for example if T
is Order
:
public class Order
{
public string OrderNumber {get; set;}
public decimal OrderWeight {get; set;}
}
the search form will be something like this:
for string
properties i want have one TextBox
, and for numeric properties, 2 Control
(one for From, and another for To)
also i want to put the user selected conditions in a predicate
variable:
Func<T, bool> predicate;
for example
predicate = t => t.OrderNumber.Contains("ORDER-01") &&
t.OrderWeight >= 100 &&
t.OrderWeight <= 200;
my questions are
how can i get all properties of a
<T>
type?how can i create this
predicate
dynamically(attach conditions to each other dynamically)?