|
This is probably a very silly question. I am opening a form(b) from within another form(a) and I am trying to get a variable from form(a) and display its contents in form(b). But I don't know how? I will also be updating the variables in form(a) from form(b)?
I have searched for ideas, but not sure what to search for?
Thanks in advance,
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
Create a public property in form B that sets the variable in form B
from Form B to A is more tricky, or you'll need to pass the object A itself to B or you'll have to create your own event.
thus in form A you'll have something like:
MyForm B = new MyForm();<br />
B.MyProperty = variablefromA;<br />
B.showDialog();
to pass the object A to form B you could pass it through the constructor (MyForm B = new MyForm(this); )
I hope for you this isn't homework...?
V.
Stop smoking so you can: enjoy longer the money you save.
|
|
|
|
|
There are generally two methods used:
1. Send a reference to form A to the constructor of form B, and store the reference in form B. Then you can access form A using the reference.
2. Make the variables in form A static, then you can access them from anywhere by specifying the class name of the form. This of course limits you to never create more than one instance of the form.
---
b { font-weight: normal; }
|
|
|
|
|
Take a look at the following article[^].
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
You beat me to it!
|
|
|
|
|
|
Hi
if I publish a version there is a version number, which increments each publish circle.
I'd like to show this number in an info-box.
But how to get it? (it ist not the Application.ProductVersion. This vesion is the number of the AssemblyInfo.cs)
Thanks
Ariadne
|
|
|
|
|
Hi ariadne,
Is this the version number you are looking for?
Assembly thisAssembly = Assembly.GetExecutingAssembly();
Console.WriteLine(thisAssembly.GetName().Version);
needs using System.Reflection;
HTH
Russ
|
|
|
|
|
No, sorry, it delivers the same as Application.ProductVersion. I need the Revison# from the published version.
Ariadne
|
|
|
|
|
Remove the .Version from the second line, and check all the methods. They are all there.
|
|
|
|
|
Hi everyone,
I'm trying to build a new set of controls for an application I'm writing. I've created a control that behaves a bit like a combo box and I've added it to a control which, in turn, I have added to a form. I designed the dropdown bit as a form so that it can be displayed outside the area of the control that I added it to. I can't find the Coordinates of the control within the main form so that I can tell the dropdown bit where to display.
Does this make sense? Does anyone know how to read these coordinates out?
Thanks in advance,
Russell
|
|
|
|
|
Hello,
I think I made a control which sounds like you descriped.
I used the 'PointToScreen' Method of my control and added the Hight of my Control as a startpoint for the Window.
MyControl c;
c.PointToScreen(new System.Drawing.Point(0, 0));
Hope that helps.
All the best,
Martin
|
|
|
|
|
Thanks very much,
just the ticket, looking good now.
Russell
|
|
|
|
|
Hi all,
I'm wanting to stretch a label dynamically.
"Autosize" only works for one line.
In order to do this I've done a manual word wrap and counted the number of lines,
Then changed the height of the label to no of lines * height.
It works after a fashion - but is there a better way to do this ?
In particular - the width of the label is in points.
The length of the string is the number of characters.
Relating the two depends on the fontsize and other spacing.
Any thoughts would be much appreciated
Cheers
Mike
|
|
|
|
|
hope this'll help you to get a better
Graphics gs = label1.CreateGraphics();
label1.Size= gs.MeasureString("label Caption",label1.Font).ToSize();
sameer
|
|
|
|
|
|
Fair warning:
I am trying to learn the new .NET way of saving configuration information, and I have found that the Configuration class's Save() method does not always work, though it raises no exceptions.
When I run my app by double-clicking the .exe file, it can save its configuration. But when running under the VS2005 debugger, not only is the configuration stored in a different file (app.vshost.exe.config instead of app.exe.config), but also Config.Save() will usually fail without raising any exception. In order to be able to save the config, I have to delete app.vshost.exe.config so that my app will recreate it.
Not to be bitchy, but I do find the irony humorous.
1. We used to write text (ini) files.
2. MS told us to use the registry instead.
3. Then MS told us never to use the registry, but use text (xml) files instead.
4. They provided the .NET 1.x way of doing things, which now results in "you shouldn't be doing this" warning messages.
5. They provided the .NET 2.x way of doing things, which (oh by the way) does not work dependably, at least under the debugger.
Is there any consensus as to what is really, truly the RIGHT way to save configuration information?
--
Charles Jenkins
"The accumulation of all powers, legislative, executive, and judiciary, in the same hands...may justly be pronounced the very definition of tyranny." "If tyranny and oppression come to this land, it will be in the guise of fighting a foreign enemy."
-- James Madison, Fourth President of the United States
|
|
|
|
|
hi,
in flex grid. i set focus a cell. at this time i want to get currosor postion x,y
how can i do this
vipin paliwal
|
|
|
|
|
use Mouse Move event of data grid.
1.create two class level integer variable
private int _xGrid=0;<br />
private int _yGrid=0;
2.now in mouse move event set value of these variables
private void dataGrid_MouseMove(sende , even e)<br />
{<br />
_xGrid=e.X;<br />
_yGrid=e.Y;<br />
} 3.use these values whereever you want
|
|
|
|
|
I want to transforming some JPG-Files to one PDF-File
in my programme, How to do it?
Thank you very much!
|
|
|
|
|
Sourceforge has some free libraries, and some commerical ones exist ( and advertise on CP from time to time )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've been using CutePDF lately, it installs as a printer and the basic version is freeware. I've been very impressed with it. I don't think it comes with an SDK though, but I haven't looked.
Russell
|
|
|
|
|
hi
i have a structure which has 3 string variable and an arraylist when i created it hasn't given any error but when i am trying to store values into the array list its giving the error like
Error cannot have instance field initializers in structs
my structure is like below
struct catalog_info
{
public string format;
public string Name;
public string connction_name;
ArrayList resourses=new ArrayList ();
}
catalog_info[] catalogs = new catalog_info[20];
|
|
|
|
|
kalaveer wrote: ArrayList resourses=new ArrayList ();
You cannot have instance field initialisers in structs. So, you can't set a default value. It's the new call that is the problem. Your arraylist is also private.
I believe you can have a constructor in a struct, set the value there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
but that initialization in the structure giving the following error
Error Field catalog_info.Name must be fully assigned before control leaves the constructor
why this error coming
please help me to avoid this error and get it work.
thanks,
kalaveer.
|
|
|
|