1,105,380 Community Members

Dynamic Controls Class Design

Member Avatar
Subha1983
Newbie Poster
7 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,
I am working on an assignment where i need to create controls dynamically in a Form and when i click "execute button" in the form it should generate a query based on the dynamic controls selection.
Each dynamic control reflect one database column.
The control's can be combo,textbox etc. The execute button is not a dynamic button.
Could you please suggest me a good approach to solve the problem..

Thanks
Subha

Member Avatar
ddanbe
Posting Expert
5,356 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

If you are using Visual Studio, you could drag a TextBow in a Forms application. See in the generated files how VS does it and act accordingly.

Member Avatar
Subha1983
Newbie Poster
7 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

The problem there is i have around 100 controls(columns) and out of that i need only 20 controls to be created dynamically based on some settings. Creating 100 controls where in i need only 20 controls, this may consume much memory space. Please suggest me..

Member Avatar
ddanbe
Posting Expert
5,356 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

Do I understand you well, do you want to have some sort of "excel-like" sheet wich fetches data from a database after pushing an execute button? Please explain a bit more.

Member Avatar
Subha1983
Newbie Poster
7 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Yes correct.. i am planning to do the same. when i select the columns and when executed it will give me the results.

Member Avatar
ddanbe
Posting Expert
5,356 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

Use a DataGridView object for that. Example
A DataGridView is rather "heavy" in the beginning to get a grasp on(I was for me!) But in the end it pays off. Success!

Member Avatar
Subha1983
Newbie Poster
7 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

You are correct but i needed to use only dynamic controls because of Look and feel.

Member Avatar
ddanbe
Posting Expert
5,356 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

In the example given the DatgridView is constructed dynamically. Or are you only allowed to use TextBoxes and ComboBoxes?

Member Avatar
Subha1983
Newbie Poster
7 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

UI design doesnt allow me to Datagridview. The search would consists of TextBox,Combox box,checked list box,checkbox,datetimectrl etc. The problem i am facing is how should i access the controls througt the file after creating the controls dynamically.

Member Avatar
ddanbe
Posting Expert
5,356 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

You could dynamically create an array of TextBox objects.
It is for example often done to create a sudoku puzzle etc.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article