Visual Studio Development Bookmark and Share   
 index > Visual C# Express Edition > How to create an app of Windows forms can drag & drop controls with C#? (Sorry if it is duplicate)
 

How to create an app of Windows forms can drag & drop controls with C#? (Sorry if it is duplicate)

<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->

Hi friends,

I was wondering this question because my accountants do not know all their needs for me to create the forms & reports to meet their requirements, so that I want to build a project in C# that allow me drag & drop controls like controls in Toolbox of .NET platform also could generate codes to modify and perform the actions to connect with database and server.

Especially, I want to load data fields from database and transform them to appropriate controls, for example, I have 2 fields in the table Customer are: CustomerName & CustomerAdd. After run my app, one it can load into the main interface of the app with 2 labels “Customer Name” & “Customer Add” with 2 textboxes for the 2 labels, respectively; otherwise, it could load these fields into a bar with interface like Toolbox in .NET, then when I drag 2 attributes from that bar to the main interface of the app, it automatically generates 2 labels and 2 textboxes correspond to 2 attributes.

Of course, after all I want to insert or update values of these attributes to database, but with unpredictable fields I could do these actions.

Could I do like that, friends?

Thank you.

(I saw the interface for user can do like that in T24 core banking of Temenos)

BatmanBegins  Monday, October 05, 2009 3:38 AM
Hi,

You might want to try to use listview which contains items with CustName representing name of label , textbox, then you can handle it with DragEnter, MouseDown, DragDrop events .

Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Tuesday, October 06, 2009 8:19 AM

Hi,

I 'm not quite sure what do you mean.
But you can create a new control with the name from database and add it to form's controls.

Please take a look at the code below:
            string Name = "a";
            //string Add = "b";
            TextBox tb = new TextBox();
            Label label = new Label();
            label.Text = Name;
            this.Controls.Add(tb);           
            this.Controls.Add(label);

            label.Location = new Point(100, 0);
            tb.Location = new Point(120,0);

Harry


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Tuesday, October 06, 2009 4:21 AM
Hi Harry,
Thank you for answering, but I think it's not easy as I think because now I can only facilely to show many attributes from database as you said. However, creating a toolbox to place attributes and dragging them into the main interface are not done.
You can suggest me a proposal for me to do a ToolBox like in .NET ?
Batman
BatmanBegins  Tuesday, October 06, 2009 5:02 AM
Hi,

What are these attributes? some icons representing controls?

Harry

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Tuesday, October 06, 2009 6:22 AM
Hi,
I meant the attributes from database. I want to merge attributes to desirably appropriate controls. For example, CustName and CustAdd become two controls in the Toolbox, when I drag them to the interface they automatically generate two labels and two textbox like in .NET platform. Is it ok ?

Batman
BatmanBegins  Tuesday, October 06, 2009 6:44 AM

I don't think it's ok.

Can CustName and CustAdd be saw as two labels and two textboxs?
What is the relationship?
Why not button or other controls?

Harry


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Tuesday, October 06, 2009 6:59 AM
Harry, I want to generate a label and a textbox for CustName also a label and a textbox for CustAdd.
To depend on each field in DB, it can be label, textbox, or checkbox.
I am thinking about the last solution for this is used vertical datagrid if it can't be done.
Batman
BatmanBegins  Tuesday, October 06, 2009 7:44 AM
Hi,

You might want to try to use listview which contains items with CustName representing name of label , textbox, then you can handle it with DragEnter, MouseDown, DragDrop events .

Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Tuesday, October 06, 2009 8:19 AM
Thanks Harry, I'll try.

Batman
BatmanBegins  Tuesday, October 06, 2009 8:55 AM

You can use google to search for other answers

Custom Search

More Threads

• Command On Close
• how to embed a bitmap (logo or immage) in c# excecutable?
• User Agents
• Battling to load template from online template library
• Cannot implicitly convert type 'int' to 'string'
• DB disconnect when Debugging
• Scope Issue
• Setting the mdiParent property from a different form than the parent
• Problem converting string to double
• Calculating the width of a label in runtime