Click here to Skip to main content
11,640,521 members (63,352 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# WindowsForms
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....
Posted 2-Aug-12 23:42pm
Aditya Mangipudi at 3-Aug-12 10:42am
Can you post some code to show what you are doing?
Sergey Alexandrovich Kryukov at 3-Aug-12 19:00pm
"Not success" is not informative. What was the problem? Creation of controls is trivial...

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^],[^],[^].

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.


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

  Print Answers RSS
0 Mika Wendelius 300
1 CPallini 209
2 OriginalGriff 165
3 Sergey Alexandrovich Kryukov 139
4 Afzaal Ahmad Zeeshan 130
0 Mika Wendelius 200
1 OriginalGriff 145
2 CPallini 115
3 jgakenhe 40
4 sasanka sekhar panda 30

Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 3 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100