|
I am new to C# and I am having some difficulty in the following task. I have a MDI parent form that calls a child form. I need to pass a reference to an object that is instantiated in the MDI parent. Should this be passed as parameter to the child form constructor? Is there a better way?
Basically I need to create the object in the parent form and have access to the same object in the child form. If the child form makes a change to the state of the object I need the parent form to have access to that change.
Thanks
|
|
|
|
|
There are many ways you could accomplish this. Having a separate property or set it in the constructor are both fine.
The question is, what do you want the object to do?
Does the child form set properties, call methods on the object?
Should this be modelled using the Model View Controller pattern?
What will the parent do with the changed object?
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
The child will change properties and call events on the object. The object is a basic business object that opens, reads and writes to text streams. Properties of this object deal with file name, creation time, etc. Methods are, SaveFile(), OpenFile(), ReadFile().
I am not familiar with the Model View Controller pattern, I will look that up. What I am trying to get is the basic calling syntax. I seem to be having problems with passing an object reference to the child form constructor.
Thanks again
|
|
|
|
|
This has already been done for you, take a look at the Form.Owner property.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
Thanks, I will check this out.
|
|
|
|
|
Hi Everyone,
Some of the .net dlls inh our application has to be shared with some client applications... So we are installing them in GAC , after strong naming them... However we are facing an issue. whenever we are changing the dlls installed in GAC, (We are not version number and snk), we have to rebuild all the application that use this file even id there is not apparent interface change... What are we doing wrong....
Regards
Sabarish
|
|
|
|
|
To share a dll, you do not have to install it into the GAC. Have you tried just copying the dll and referencing it in the other application?
As far as referencing assemblies in the GAC, you can click on a reference in your project (whether a reference to a GAC assembly or a non-GAC'd assembly) and specify whether the app requires a specific version.
Does that help?
|
|
|
|
|
Hi Judah,
The first otpion does not suite with the client, they do not want any of our dlls where their application is installed.... our will be in 1 folder and theris in another...
The second option we had tried, but the issue is that we have toi change in about 50 project
|
|
|
|
|
Sabarish_s wrote: but the issue is that we have toi change in about 50 project
Well, if it solves your problem, perhaps that is the best bet.
|
|
|
|
|
References to strong-named assemblies are bound to that specific version number. There's no other way because there could be multiple versions of the assembly in the GAC.
However, you can redirect the assembly bindings using a publisher policy[^].
|
|
|
|
|
i working with c# 2005
i have toolbar in the form that contain nevigations button(first row -last row -next row -previous row)
i want to select rows not by mouse but with theses buttons how?!
and if the selected row is not appear the datagrid scrollbar scrolls to show selectd row
plz answer me quickly ?!!
ma_refay
|
|
|
|
|
ma_refay wrote: plz answer me quickly ?!!
How quickly do you need it?
|
|
|
|
|
How quickly do you need it?
Today in any way
thanks alot
ma_refay
|
|
|
|
|
|
Don't be hard on him Martin
his English seems to be some how poor.
|
|
|
|
|
Are you doing anything other than scrolling the data? Are you placing data from the grid into other controls to edit them?
Either way, I'd suggest this article here[^] as a good reference.
|
|
|
|
|
Hi,
Is it possible to launch the Windows ODBC Data Source Administrator from within an application?
|
|
|
|
|
Hi,
I'm writing a COM interop interface in C# (VS2005) to be used in VC++, and got into problem of proper exporting enum-s in such interface.
When i previously used C++ for writing COM interfaces, i would just declare the enum within IDL file, and then within the library section also declare it, that way way making my enum accessible when TLB file is imported using #import in C++;
Now in C# if i declare: public enum MyEnymType {val1, val2,...}, then such object when imported into C++ project is declared as: enum MyEnymType {MyEnymType_val1, MyEnymType_val2,...} instead of enum MyEnymType {val1, val2,...}
Is there a way to make C# embed my enum type into the object in such a way that it exports original enum declaration during import instead of such an ugly Type_Value thing?
Thank you,
Vitaly
|
|
|
|
|
I don't know enough C++ to give a definite answer, but this is what I think:
I think that each enum value has to be a unique identifier in C++, while in C# they only have to be unique within the enum. That would account for the need of prepending each value with the name of the enum.
---
Year happy = new Year(2007);
|
|
|
|
|
This is true, C++ doesn't allow the same enum variables within different enum declarations, but if i'm sure that i have unique variables within my enum, shouldn't there be a way to override for C# compiler to use original names instead for variables within enum? 'Cos this is what i'm looking for, if it is possible....
Free C++ libraries with source code on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...
|
|
|
|
|
Just because you're sure that the enums will be unique in your class doesn't guarantee that it will be unique against another class. Here the compiler is trying to protect you from yourself (even though you don't want it to).
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
My question was "Is this C# behavior overridable?"...
Free C++ libraries with source code on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...
|
|
|
|
|
VitalyTomilov wrote: My question was "Is this C# behavior overridable?"...
And my answer is no. In it's infinite wisdom, MS has decided that you thinking you know best is a bad thing. Hence, my answer above.
How dare you know your own mind
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Possibly if you use a custom modified version of the mono compiler. Otherwise no.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Nice icon GUFFA
Congratulations for the MVP
|
|
|
|