Click here to Skip to main content
15,892,643 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to open and read a file as a unicode char Pin
Luc Pattyn4-Aug-07 0:17
sitebuilderLuc Pattyn4-Aug-07 0:17 
AnswerRe: How to open and read a file as a unicode char [modified] Pin
Guffa4-Aug-07 0:51
Guffa4-Aug-07 0:51 
AnswerRe: How to open and read a file as a unicode char Pin
Mike Dimmick4-Aug-07 3:36
Mike Dimmick4-Aug-07 3:36 
QuestionIs it possible to enable controls on the form from a class. Pin
Janu_M3-Aug-07 23:23
Janu_M3-Aug-07 23:23 
AnswerRe: Is it possible to enable controls on the form from a class. Pin
Luc Pattyn3-Aug-07 23:54
sitebuilderLuc Pattyn3-Aug-07 23:54 
GeneralRe: Is it possible to enable controls on the form from a class. Pin
Janu_M4-Aug-07 0:11
Janu_M4-Aug-07 0:11 
GeneralRe: Is it possible to enable controls on the form from a class. Pin
Colin Angus Mackay4-Aug-07 0:26
Colin Angus Mackay4-Aug-07 0:26 
GeneralRe: Is it possible to enable controls on the form from a class. Pin
Luc Pattyn4-Aug-07 0:32
sitebuilderLuc Pattyn4-Aug-07 0:32 
If you hold a reference to the form, you can manipulate everything on it that is
declared public, as in myForm.myButton.Enabled=true;

But it is considered bad design to make controls public, since everyone holding
the reference (myForm) can also replace, resize, move, hide, ... said control.
In fact, it is almost always wrong to provide public fields, only methods and
properties should be candidates for the public attribute.

An acceptable approach is:
- keep the controls private (or protected) to your form class;
- provide public methods (or properties) inside your form class, that offer
the required functionality to the outside world, no more, no less;
- pass the form's reference to your class and have it use the public methods
or properties.

And if you are familiar with delegates, they offer the best approach. It basically
means your form creates a delegate (that's like a function pointer connected
to the form's object), so now it can pass that delegate to your class, without
even having to pass the form's reference itself. That is encapsulation, provide
as little as possible, just give what is absolutely necessary.

Smile | :)


AnswerRe: Is it possible to enable controls on the form from a class. Pin
Developer6114-Aug-07 0:14
Developer6114-Aug-07 0:14 
AnswerRe: Is it possible to enable controls on the form from a class. Pin
Manoj Kumar Rai4-Aug-07 0:27
professionalManoj Kumar Rai4-Aug-07 0:27 
GeneralRe: Is it possible to enable controls on the form from a class. Pin
Colin Angus Mackay4-Aug-07 0:33
Colin Angus Mackay4-Aug-07 0:33 
GeneralRe: Is it possible to enable controls on the form from a class. Pin
Manoj Kumar Rai4-Aug-07 0:37
professionalManoj Kumar Rai4-Aug-07 0:37 
AnswerRe: Is it possible to enable controls on the form from a class. Pin
Janu_M4-Aug-07 0:41
Janu_M4-Aug-07 0:41 
GeneralRe: Is it possible to enable controls on the form from a class. Pin
Developer6114-Aug-07 0:44
Developer6114-Aug-07 0:44 
QuestionTo genrate a log in text box Pin
Hum Dum3-Aug-07 21:49
Hum Dum3-Aug-07 21:49 
AnswerRe: To genrate a log in text box Pin
Christian Graus3-Aug-07 22:03
protectorChristian Graus3-Aug-07 22:03 
GeneralRe: To genrate a log in text box Pin
Hum Dum3-Aug-07 22:28
Hum Dum3-Aug-07 22:28 
QuestionHOw can I recreate .sln file that was deleted by system restore Pin
TheCat0073-Aug-07 20:25
TheCat0073-Aug-07 20:25 
AnswerRe: HOw can I recreate .sln file that was deleted by system restore Pin
Christian Graus3-Aug-07 21:15
protectorChristian Graus3-Aug-07 21:15 
GeneralRe: HOw can I recreate .sln file that was deleted by system restore Pin
TheCat0075-Aug-07 4:13
TheCat0075-Aug-07 4:13 
AnswerRe: HOw can I recreate .sln file that was deleted by system restore Pin
Eliz.k4-Aug-07 4:05
Eliz.k4-Aug-07 4:05 
Questionquery about ticker. Pin
Ravikumar Patra3-Aug-07 20:24
professionalRavikumar Patra3-Aug-07 20:24 
AnswerRe: query about ticker. Pin
Christian Graus3-Aug-07 21:17
protectorChristian Graus3-Aug-07 21:17 
GeneralRe: query about ticker. Pin
Ravikumar Patra4-Aug-07 7:51
professionalRavikumar Patra4-Aug-07 7:51 
Questionconfiguaration file Pin
pavanteja3-Aug-07 20:11
pavanteja3-Aug-07 20: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.