Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear All,

i want to set the location of created dynamic control from the database. i have 2 records with 2 fields in table. so i want to set 1 record in 1st row and then 2nd record in 2nd row..

i am not success to set the location of dynamic controlllll...

please help...


Thanks and Regards....
Mitesh
Posted
Comments
Aditya Mangipudi 3-Aug-12 10:42am    
Can you post some code to show what you are doing?
Sergey Alexandrovich Kryukov 3-Aug-12 19:00pm    
"Not success" is not informative. What was the problem? Creation of controls is trivial...
--SA

1 solution

There are no dynamic vs. non-dynamic controls. They are all equally "dynamic".

There are two things you might no understand. First, avoid finding location for a control. Instead, prefer using docking in combination of padding. In some cases, anchors could be useful, but they can create some flicker on resize, depending on what's anchored. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.padding.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.anchor.aspx[^].

However, as absolute position is hardly acceptable if you are using the Designer, it can be used when you position controls "dynamically", which just means manually written code, without using the Debugger. By the way, manually written code is more supportable.

You might have another problem, writing the code inserting controls. Basically, it's done using Control.Controls.Add (for a parent control) or assigning a parent reference to Control.Parent, but I usually also recommend a very universal method of learning how to insert/arrange control. Add few control as you like using the Designer, temporarily, just for learning purpose. Look at the auto-generated code. You can easily learn how to code the same thing in your code.

—SA
 
Share this answer
 

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