Click here to Skip to main content
15,910,009 members
Home / Discussions / C#
   

C#

 
QuestionMonth Calendar Pin
kenexcelon30-Sep-05 15:33
kenexcelon30-Sep-05 15:33 
AnswerRe: Month Calendar Pin
g00fyman1-Oct-05 1:36
g00fyman1-Oct-05 1:36 
QuestionAutoPlay handling in C# (IQueryCancelAutoPlay) Pin
Member 83101330-Sep-05 15:12
Member 83101330-Sep-05 15:12 
QuestionCan't get variables into Watch1 in Debug Pin
Anonymous30-Sep-05 14:58
Anonymous30-Sep-05 14:58 
AnswerRe: Can't get variables into Watch1 in Debug Pin
Guffa30-Sep-05 23:42
Guffa30-Sep-05 23:42 
QuestionInterface Icons Pin
Anonymous30-Sep-05 14:12
Anonymous30-Sep-05 14:12 
QuestionHow to write a user defined windows control??? Pin
Ming Luo30-Sep-05 11:48
Ming Luo30-Sep-05 11:48 
AnswerRe: How to write a user defined windows control??? Pin
Jon Rista30-Sep-05 12:23
Jon Rista30-Sep-05 12:23 
There are generally two types of visual controls as far as .NET/Windows Forms is concerned. You have the Control, which is not a combination of other controls, but a class (and possible support classes) written with painting code, user input handling code, windows message handling code, etc. Then there is the UserControl, which is a simple form surface without a frame that you can combine multiple, existing controls onto, and which has its own, localized event handling loop.

If you just want to combine existing controls to make a reusable interface with say, a label, textbox, button, and filebrowserdialog, you could create a simple usercontrol that lets you browse for a path. You can create events, properties, and methods for this usercontrol, so you can interact with it and respond to it wherever you use it (i.e., on another form or even another user control).

Writing pure, custom controls is quite a bit more complex. You have to write the whole thing from scratch. That includes drawing every aspect of the visual representation, handling keyboard and mouse input, responding to windows messages, and generating events for when things happen on your control (i.e. the user clicked a certain part of the control, or they double-clicked it). Depending on exactly what kind of control your writing, you may need support classes and collections to store listed data, or if your writing a container control, you have to support child controls and proper placement of those child controls.

Custom controls also don't integrate well into the Visual Studio .NET designer unless you directly code for it. This means properly attributing your code to support he property editor, as well as attributing your code with custom type converters and visual designers. There is also the aspect of data binding for custom controls, which, suffice to say, adds a whole nother layer of complexity.

So, to put all that simply. If you have never written a custom control before, start with UserControls (they are a type of form you can create in VS.NET). Once you learn how to create complex user controls, and learn how to create and handle events from your user controls, you could move on to true custom controls. True custom controls, properly written to support the design time environment, data binding, and support interaction with other code (through properties, methods, and events), can easily take 10 times as much code or more than a UserControl. Writing custom controls is very fun, but pace yourself if you really want to learn them. UserControls are a perfect introduction to the world of custom controls.
GeneralRe: How to write a user defined windows control??? Pin
Ming Luo30-Sep-05 23:55
Ming Luo30-Sep-05 23:55 
GeneralRe: How to write a user defined windows control??? Pin
Jon Rista1-Oct-05 8:08
Jon Rista1-Oct-05 8:08 
AnswerRe: How to write a user defined windows control??? Pin
Heinz_30-Sep-05 17:48
Heinz_30-Sep-05 17:48 
GeneralRe: How to write a user defined windows control??? Pin
Jon Rista1-Oct-05 8:10
Jon Rista1-Oct-05 8:10 
QuestionForm2 DataAdapter/DataSet Pin
rich_wenger30-Sep-05 10:28
rich_wenger30-Sep-05 10:28 
Questionpassing record between forms Pin
mpw_30-Sep-05 9:37
mpw_30-Sep-05 9:37 
AnswerRe: passing record between forms Pin
Robert Rohde30-Sep-05 9:51
Robert Rohde30-Sep-05 9:51 
GeneralRe: passing record between forms Pin
mpw_30-Sep-05 10:24
mpw_30-Sep-05 10:24 
QuestionWhen to use Int32.Parse(... vs. Convert.ToInt32(... Pin
...---...30-Sep-05 9:20
...---...30-Sep-05 9:20 
AnswerRe: When to use Int32.Parse(... vs. Convert.ToInt32(... Pin
Robert Rohde30-Sep-05 9:48
Robert Rohde30-Sep-05 9:48 
AnswerRe: When to use Int32.Parse(... vs. Convert.ToInt32(... Pin
mpw_30-Sep-05 10:19
mpw_30-Sep-05 10:19 
QuestionConnection between two C# program Pin
Yanshof30-Sep-05 9:13
Yanshof30-Sep-05 9:13 
AnswerRe: Connection between two C# program Pin
DavidNohejl30-Sep-05 9:30
DavidNohejl30-Sep-05 9:30 
QuestionHow to calculate the nearest color? Pin
bouli30-Sep-05 9:07
bouli30-Sep-05 9:07 
AnswerRe: How to calculate the nearest color? Pin
DavidNohejl30-Sep-05 9:27
DavidNohejl30-Sep-05 9:27 
QuestionCSharpCodeProvider generated EXE embedded with ResourceWriter generated .resources fails... Pin
Jon Rista30-Sep-05 6:43
Jon Rista30-Sep-05 6:43 
AnswerRe: CSharpCodeProvider generated EXE embedded with ResourceWriter generated .resources fails... Pin
Jon Rista1-Oct-05 8:11
Jon Rista1-Oct-05 8:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.