Reputation: 1526
I have to create a form in which the user can select fields from a listbox on which he wants the search criteria and then the controls are created according to the selection of the user from the listbox,for example if the listbox consist of fields like
1. Name
2. Age
3. Department
4. Designation
and if the user wants to have a search based on the Name
and Designation
then he will select Name
and Designation
from list box and the two text boxes will be created in the search panel with their respective lables,
And if the user wants to put the search criteria on Age
then he can replace the previously selected Name
and Designation
field with Age
and then only 1 TextBox will be created with label age in the search panel,
So what is the best possible way to achieve this requirement,please suggest me,any sort of help will be highly appreciable
Thanks in Advance
Upvotes: 0
Views: 1574
Reputation: 2074
Adding controls dynamically is not a hard concept, Just do searches for adding controls dynamically to whatever UI technology you are using.
Here is a basic tutorial that adds a Textbox to a webform http://www.c-sharpcorner.com/UploadFile/0c1bb2/adding-web-forms-controls-dynamically-in-Asp-Net-C-Sharp-web-appl/
Using JQuery http://totaldotnet.com/article/showarticle130_dynamiccontroljquery.aspx
A question about adding to WPF WPF: How to dynamically Add Controls in dynamically created WPF Window
Or Windows Form, http://anthonystechblog.wordpress.com/2009/11/12/net-c-how-to-dynamicall-add-controls-to-a-form-and-hook-up-their-events/
Upvotes: 1