|
Put a parameter in the constructor of the form:
public Form1(string[] args)
Pass the arguments when creating the form:
Application.Run(new Form1(args));
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks,
but in general, how do I pass variables between classes in a window application? Do I always have to pass as arguments? or there are some namespace level variable I can use? I was a VB programmer so I've been spoiled that there are always application level variables to use.
|
|
|
|
|
Just make it public
You can make it static to pass it through the class name
or you can create an instance from class2 into class1 to access non static members
Mohamed Gouda
Egypt
|
|
|
|
|
Mohammed Gouda wrote: Just make it public
Make what public? A field on the class. That is extremely bad practice: see Why make fields in a class private, why not just make them public?[^] and The public fields debate again[^]
Mohammed Gouda wrote: You can make it static to pass it through the class name
And what happens when you have many instances of the same class? You pass the value to the static field and then you immediately affect all instances of the class rather than the one you are interested in.
Mohammed Gouda wrote: you can create an instance from class2 into class1 to access non static members
I just don't understand where you are going with that.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Hey !!
Colin Angus Mackay wrote: That is extremely bad practice
Thanks
One of your solutions is using properties (get and set)
Can you plz explain the difference between creating a Read/Write property for a private member AND making that member public?
I think making a Read/Write property is a redundant code (MAY BE I AM WRONG)
And when I diside to make a Read/Write property this means I will permit external Read/Write acces to the member (which can be achieved shortly be the keyword public)
Mohamed Gouda
Egypt
|
|
|
|
|
Sure,
if you want to allow someone to set a text in one of your labels, you could:
1. provide a public property (or method) that does exactly that; this is good
2. make the label public, or provide a public property that gets a reference to the label,
so the caller itself can set the text. this is bad. Why ? because now the caller can
do many more things to your label, such as moving it around, changing its color, etc,
all things you did not intend to allow.
Hence: provide public properties/methods to do exactly what is needed, no more, no less.
|
|
|
|
|
Mohammed Gouda wrote: Can you plz explain the difference between creating a Read/Write property for a private member AND making that member public?
Read the links I gave you.
Mohammed Gouda wrote: And when I diside to make a Read/Write property this means I will permit external Read/Write acces to the member (which can be achieved shortly be the keyword public)
You are not granting read/write directly to the field, you are offering a way to access the field. If you read the links I gave you then you would already be aware of the advantages of that. In fact, there might not even be a field there at all. You are also giving your class the opportunity to veto any value that the outside class attempts to set on the field.
In short, there are vary few situations where making a field public is acceptable. Again, you would have seen that if you read the links I gave.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
mhp130 wrote: but in general, how do I pass variables between classes in a window application?
Regardless of application type you can pass variables through constructor parameters, method parameters or properties.
mhp130 wrote: or there are some namespace level variable I can use?
Good grief no! That is extremely bad practice.
mhp130 wrote: I was a VB programmer so I've been spoiled that there are always application level variables to use.
That's not being spoiled, that's picking up bad habits... Which I suppose happens if you get spoiled also..
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
How to embedd a Windows form in a Webform
f
|
|
|
|
|
ankit_mait wrote: How to embedd a Windows form in a Webform
Can we?
FYI, you can not. By the way, if you post what exactly you wanna do, thn some can help you
|
|
|
|
|
Yeah you can. It's generally not a good idea, but you can.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I actually want to create an online Sudoku Solver so i thought i can create a windows application and then embedd it in an Webform...
This seems a little foolish but actually i have a 4 day time constraint and even if i cant create the webform i can atleast show an application to my professor
|
|
|
|
|
It is possible, but I don't care to explain as it is very heavy to run on the server and you are probably better of building a true web application.
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
My blog
|
|
|
|
|
Hello,
I want to put a button on form which should give and appearance like "pressed" when clicked first time and it should come out on second click.
How can i implement this??
Thanks.
Gajesh
|
|
|
|
|
There's a property for the CheckBox class that makes it appear like a button. In combination with setting Checked to true during startup that's exactly what you want.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks.
It is fine for my requirement.
Gajesh
|
|
|
|
|
hi
i am wondering where can i find some article about using dataset.xsd in windows form in C#?
thanks so much
|
|
|
|
|
Here perhaps?[^]
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
do u have any sample code please
|
|
|
|
|
Sure.
Here.[^]
P.S.: Are you starting to see a pattern?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
mav.northwind wrote: Are you starting to see a pattern?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
please tell me how to compile or convert html to XML. Please tell me How compilation differs from convert. Thanks
|
|
|
|
|
Well, HTML is essentially XML, and neither are really compiled in the traditional sense. What do you want as your output?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Steve Echols wrote: Well, HTML is essentially XML,
Not really, XML is more strict. Some things perfectly legal in HTML are invalid in XML.
[ My Blog]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
1)Parse HTML
2)Create DOM
3)Save DOM in XML
Or, use HTML Tidy[^].
[ My Blog]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|