Click here to Skip to main content
15,886,689 members
Home / Discussions / Windows Forms
   

Windows Forms

 
AnswerRe: hi everyone! Pin
JP_Rocks17-Jan-12 1:03
JP_Rocks17-Jan-12 1:03 
GeneralRe: hi everyone! Pin
Shameel19-Jan-12 19:09
professionalShameel19-Jan-12 19:09 
AnswerRe: hi everyone! Pin
ProEnggSoft18-Feb-12 5:53
ProEnggSoft18-Feb-12 5:53 
Questionc# Winforms with classes. Pin
Cliffordagius29-Dec-11 6:56
Cliffordagius29-Dec-11 6:56 
AnswerRe: c# Winforms with classes. Pin
Eddy Vluggen29-Dec-11 8:57
professionalEddy Vluggen29-Dec-11 8:57 
AnswerRe: c# Winforms with classes. Pin
Luc Pattyn30-Dec-11 0:06
sitebuilderLuc Pattyn30-Dec-11 0:06 
AnswerRe: c# Winforms with classes. Pin
Shameel2-Jan-12 2:12
professionalShameel2-Jan-12 2:12 
GeneralRe: c# Winforms with classes. Pin
BillWoodruff18-Jan-12 13:02
professionalBillWoodruff18-Jan-12 13:02 
Picky-picky: the use of identical names, for both Property Type, and Property Name, in the 'internal Property definition above ... uhh ... makes me nervous Smile | :) Yes, it will compile, but I think that then becomes ambiguous code that degrades future maintainability.

Consider: we define 'MyClass this way:
C#
public class MyClass
{
    // default 'ctor
    public MyClass() {}

    // 'ctor where PacketSize is passed in as a parameter
    public MyClass(int pSize)
    {
        PacketSize = pSize;
    }

    public int PacketSize { get; set; }
}
Then, in the "main form:"
C#
private static MyClass myClassInstance1;

public static int PacketSizeInMyClass1
{
    get
    {
        return myClassInstance1.PacketSize;
    }
}

AdminForm adminForm = new AdminForm();

private void MainForm_Load(object sender, EventArgs e)
{
   myClassInstance1  = new MyClass(256);

   adminForm.Show();
}
Now, in the instance of 'AdminForm, we can directly access the PacketSize value in the instance of MyClass:
int pSize = MainForm.PacketSizeInMyClass1;
This is only one variation of many possible approaches to narrowing the scope of what is exposed, and eliminating complex look-ups (as in your example, where you have to re-create the instance of MainForm by de-referencing this.MDIParent every time you want to access the value of PacketSize).

And, each scenario's requirements may demand different approaches: if, using the scenario above there is one and only one instance of MyClass ever created: then that class can be made static, and the code simplified futher.

In the example here, we've gone to perhaps awkward lengths to leave MyClass a dynamic class that could have more than one instance created (although, obviously, we haven't shown any other instantiation and its use).
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle

AnswerRe: c# Winforms with classes. Pin
BillWoodruff18-Jan-12 11:56
professionalBillWoodruff18-Jan-12 11:56 
QuestionHow can a display msg file to user in Reply/ReplyAll/Forward mode just like outlook mailitems ? Pin
Tanuja12316-Dec-11 2:20
Tanuja12316-Dec-11 2:20 
QuestionScreen scraping C# Pin
Richard MacCutchan13-Oct-11 5:41
mveRichard MacCutchan13-Oct-11 5:41 
AnswerRe: Screen scraping C# Pin
Luc Pattyn13-Oct-11 6:23
sitebuilderLuc Pattyn13-Oct-11 6:23 
GeneralRe: Screen scraping C# Pin
Richard MacCutchan13-Oct-11 7:39
mveRichard MacCutchan13-Oct-11 7:39 
GeneralRe: Screen scraping C# Pin
Ravi Bhavnani13-Oct-11 17:24
professionalRavi Bhavnani13-Oct-11 17:24 
GeneralRe: Screen scraping C# Pin
Richard MacCutchan13-Oct-11 22:48
mveRichard MacCutchan13-Oct-11 22:48 
GeneralRe: Screen scraping C# Pin
Richard MacCutchan16-Oct-11 1:42
mveRichard MacCutchan16-Oct-11 1:42 
AnswerRe: Screen scraping C# Pin
Luc Pattyn16-Oct-11 5:39
sitebuilderLuc Pattyn16-Oct-11 5:39 
GeneralRe: Screen scraping C# Pin
Richard MacCutchan16-Oct-11 6:41
mveRichard MacCutchan16-Oct-11 6:41 
GeneralRe: Screen scraping C# Pin
Richard MacCutchan1-Dec-11 0:32
mveRichard MacCutchan1-Dec-11 0:32 
GeneralRe: Screen scraping C# Pin
BillWoodruff11-Dec-11 9:22
professionalBillWoodruff11-Dec-11 9:22 
GeneralRe: Screen scraping C# Pin
Richard MacCutchan11-Dec-11 22:18
mveRichard MacCutchan11-Dec-11 22:18 
Questiontry to learn Pin
smokindinesh7-Oct-11 18:02
smokindinesh7-Oct-11 18:02 
AnswerRe: try to learn Pin
DaveyM697-Oct-11 23:58
professionalDaveyM697-Oct-11 23:58 
AnswerRe: try to learn Pin
RobCroll10-Oct-11 12:00
RobCroll10-Oct-11 12:00 
AnswerRe: try to learn Pin
Eddy Vluggen22-Oct-11 0:00
professionalEddy Vluggen22-Oct-11 0:00 

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.