|
thanks nbobby,
this looks just like what I'm after.
best regards,
John
John
|
|
|
|
|
Keep in mind that this is a different instance, not the same instance created in the other page. A class and a class instance (as you mentioned in your subject) are two different things. Classes can be referred to from anywhere so long as the assembly in which the class is defined can be loaded, and that the class is not inaccessible due to its accessibility modifier (like an internal class). To keep the same instance you need to keep the instance alive. For per-user instances you can use the Page.Session variable. See my other reply for more details.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath you r correct ... i cant access the value that i set for the object variable in the class2.
What does this mean ...
im creating the Windows application
|
|
|
|
|
In order to access an instance of a class you must access the instance itself. Being able to use the class doesn't mean anything (unless it's a singleton, which is accessed different depending on the context). In a Windows Forms appliation this is much different than an ASP.NET application, where each page (or other handled type) is short-lived and runs in a separate thread for only as long as the page is processed. Instances of pages are not kept alive like Windows Forms. To access an instance of a class (an object) within another form you must pass a reference to that object, or to the form in which the field or property that returns that object is accessible (public or internal).
Windows Forms appliations and ASP.NET web applications are very different from each other, regarding how they are executed. They even run within different CLR hosts. MSDN has lots of information about the execution models for both types of applications.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
very helpful info Heath,
thanks
(I'm using session!)
John
|
|
|
|
|
Thanks Heath
I used the same refernce pass in windows application
|
|
|
|
|
I enbaled the top most property of a child form to make it remain on the top of the application window, although not to my knowledge this set the form to be the top most of every other window as well, can anyone tell me how I can get the form to only remain on top the application window and now all the native XP windows. Thanks
Ruskin
|
|
|
|
|
dont use Top Most therefore set top most property to false, set the child form's Owner property.
say
ChildForm child = new ChildForm;
child.Owner = this;
"this" implies tie it to the parent form.
|
|
|
|
|
Thanks that helps a lot, but there is still a small problem.
Say I have a MDI container which can have several different windows within it. Say the main MDI window is 'A', it has a child window within it called 'B' and another child window called 'C'. Now window 'B' opens another small window 'D' which I want to be on top, but I only want it to be on top of 'B' and not on top of 'C', can i achieve that?
|
|
|
|
|
I don't think you can. If you created the form by itself, and set it's Owner property to A, it would always be above A. But if you want to do that for a MDI child on another MDI child, sorry but you can't.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Yeah I had a look around, if a form is an MDI child, and that opens another window which you want on top of the mdi child which opened it and not any other mdi child, that is not possible
Is there any way around so we can simulate that behaviour?
|
|
|
|
|
Ruskin Dantra wrote: Is there any way around so we can simulate that behaviour?
I looked around at it a little bit, and no, I can't think of anyway to simulate it. MDI was just not designed to do that. Sorry!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
How to get a reference to string? I mean that I want to have 2 string objects, that both point to the same string in a memory
|
|
|
|
|
A System.String (string in C#) is a reference type, so the following are equal:
string a = "Hello, world!";
string b = a;
Console.WriteLine(object.ReferenceEquals(a, b)); Strings are immutable, however, so as soon as you change one string - which actualy returns a copy of the string with your changes - the references are not equal. It's also important to note that string equality (the == operator) is based on the content and not the reference.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I'm trying to plan abit of code for a space game and I've ground to a halt.
Here's a theory:
A Class called Object which might have some properties like Location.
Two other classes inherit this object, Planet and SpaceStation. And they their own methods and properties appropriately.
Simple so far.
Ok, so I want to create planets and spacestations and chuck them into a collection, I guess Universe.
so questions:
1) Does a class inserted into a collection always have to be exactly the same as the other existing in there?
2) If I loop through all the classes within the collection, how do I tell whether one class is a Planet or if its a SpaceStation?
Any response gratefully appreciated.
Andy
|
|
|
|
|
Avoid naming the class Object, or you will have to specify the full namespace every time you use it, as there is a class named Object in the System namespace.
You can either create a typed collection for objects of the base class, or use an untyped collection, like an ArrayList or a Hashtable. For a typed collection, you can use any member that you declared in the base class without type casting the objects. For an untyped collection, you have to type cast the objects to the base class or the specific class before using them.
To check the class of an object, you use the in operator:
if (anObject is Planet) {
((Planet)anObject).SomeMethod();
} else {
((SpaceStation)anObject).SomeOtherMethod();
}
---
b { font-weight: normal; }
|
|
|
|
|
Thankyou.
Is there is any reason, or preference in using hashtables or Arraylists rather than collections?
I sort of assumed that using collections would be better to form a hierachy structure.
Such as some like....
Console.Writeline (myUniverse.SpaceObjects[0].ShipsDocked[1].ShipName.ToString())
Im guessing if I use an arraylist, then I would need to include an index field in all of my classes, to associate them to their parents?
If I'm regularly performing looping through all spaceobjects, to trigger some method for each, what would be quicker, collections or arraylists?
Or am I going down the wrong route here?
|
|
|
|
|
Hastable and ArrayList are collections.
---
b { font-weight: normal; }
|
|
|
|
|
Hi there!
I have a couple of spotlights controlled from the computer, and would like to flash these in the same beat as the music I'm playing.
Therefore i need to analyse the music i play in Winamp (or if its easyier, the main mixer) and by an lowpassfilter or equal get every beat from the music.
This couldn't be to hard i guess, because there is plenty of visual plugins to winamp reacting to Music.
Writing a winamp plugin analysing the music in winamp and sending the "beats" to my C# controlling app is one way. Or?
How to write a winamp plugin? How do communicate? How do analyse the beat?
Tell me your ideas!
----------------------------------------------
Johan Böhlin
Student at Chalmers university of technology, Sweden.
CS
johboh@student.chalmers.se
----------------------------------------------
|
|
|
|
|
Check the documentation for creating plugins for winamp. I think that there already is a beat analyzer built in, at least there was one in the Advanced Visualization Studio in Windamp 2.80.
---
b { font-weight: normal; }
|
|
|
|
|
Hi there!
Do you know any "How-to: Winamp plugin in C#", or should i use google?
----------------------------------------------
Johan Böhlin
Student at Chalmers university of technology, Sweden.
CS
johboh@student.chalmers.se
----------------------------------------------
|
|
|
|
|
Have you checked on http://www.winamp.com/ ?
Otherwise go google.
---
b { font-weight: normal; }
|
|
|
|
|
Hi there.
I have an app that has several menus. I want that when a certain menuItem(s) is/are selected other menuItems are disabled. For instance, if a user selects menuItem2 I want menuItems 10, 12 and 17 to be disabled. How do I go about coding that?
I know about Enable = false but I don´t know how to code: if such and such menuItems are selected then such and such menuItems are to be disabled.
Thanks,
FJ
|
|
|
|
|
Are you talking about menu items with CheckBox's ?
Something this simple might help:
menuItem3.Enabled = (menuItem1.Checked && menuItem2.Checked && ...);
Enjoy,
David
|
|
|
|
|
Hi.
No, what I mean is to have a menuItem like Paste grayed out unless you have something on the clipboard, one can´t paste unless something is on the clipboard. Once you have something on the clipboard Paste becomces selectable, not grayed out. I want certain menuItems to be grayed out if some other menuItem is selected.
Thanks,
FJ
|
|
|
|