views:

1211

answers:

2

Hi all,

In ASP.NET you have something called "User Controls", which allow you to design a custom control which can be reused in the website.

I am now starting developing a Windows application in .NET 2.0 and (surprisingly) I cannot find a similar functionality.

What I would like to do is: - Create a new user control in the designer; - Drag & Drop a few controls on it (e.g. buttons, textboxes); - Save, and be able to resuse this user controls by dragging and dropping it on various dialogs.

Any suggestion would be greatly appreciated.

Thank you, Giammarco Schisani

+3  A: 

UserControl

Step-by-step guide to create, add and use UserControls in WinForms applications: http://www.devcity.net/Articles/87/ssteps_customcontrol.aspx

Main steps are:

  • Create a library project
  • Add or customize the default UserControl
  • Build the project
  • Add a new windows application project
  • Open the Form in the designer: your new control appears.
boj
+1 : Just the right link, was always well awarded in expertsExchange, I remember. At SOF this beheviour still have to kick in a bit more
Peter
Ehem...refresh before comment pls
boj
@Peter: There are philosophic reasons behind this behavior. This place is going to be Wikipedia in programming field. It's more community-oriented than *solve the guy's problem and go*.
Mehrdad Afshari
@boj lol, and @Mehrdad , tx for the info.
Peter
@boj, thank you, but this is not exactly what I was looking for. I wonder if there is a way to achieve this using the designer, as we do in ASP.NET.
Giammarco Schisani
boj
+1  A: 

Ok, this is not an answer on you question, but sth. I wish someone said to me when I started winforms : if you have any choice : at least concider WPF.

I'm afraid you haven't though, or is there a reason you are using .NET 2.0?

Peter
Yes, and best of all, it's great fun!
Peter
The main reason why I do not go for WPF is that I do not have time to waste studying new stuff which do not bring any great benefit to me. WPF brings with it major disadvantages, including that it cannot be ported to linux using Mono.
Giammarco Schisani
Portability, fair enough.But that's about the one and only reason I would ever return to winforms. The advantages easily outplay the disadvantages.
Peter