|
I want to access a variable and get its value.This variable was created in old form which is called. And now I'm being a new form. Pleased show me!
Thank you!
|
|
|
|
|
dont create the variable in the form load event.
create a separate class in the namespace of the old form
once you have done that, u can use the variable using the classname and the dot operator.
as classname.variable name
like, mySeparateClass.globalVariable1
Keshav Kamat
India
|
|
|
|
|
One metod is to create a new metod to show the new form.
public void myshow(object param)
{
this.Show();
this.param=param;
}
|
|
|
|
|
you can access that variable in any form, using the class name
Keshav Kamat
India
|
|
|
|
|
Keshav V. Kamat wrote: you can access that variable in any form, using the class name
No. You can't. He described an instance field. Not a static field.
|
|
|
|
|
Overload default constructor of the new form and pass the old form object to this constructor. Use that object to access the value
|
|
|
|
|
Can you can show me more clearly? May be give me some code? I'm a beginner. Thank you very much!
|
|
|
|
|
namespace Sample
{
public partial class Form1 : Form
{
}
// create a separate class here
public class mySeparateClass
{
public static int globalVariable=new int();
}
}
Once you have done that, u can access the variable globalVariable, anywhere in all the forms of the project using the classname as follows.
mySeparateClass.globalVariable
try it.;)
Keshav Kamat
India
|
|
|
|
|
Global variables are generally an indication of a poor design. If you feel compelled to use a global variable your first thoughts should be: Is there a better way to do this? If not, then fine, use the global variable. But they should not be your first option.
|
|
|
|
|
|
Please show me how to creat a variable that can use in all form in my project.I'm learning C#.NET 2005.
|
|
|
|
|
create a separate class like below
public class mySeparateClass
{
public static int globalVariable1 = new int();
}
then you can use the variable globalVariable1 as mySeparateClass.globalVariable.
check it out.
i hope this works.
Keshav Kamat
India
|
|
|
|
|
Declare a variable as static
public static int myvar=1;
|
|
|
|
|
Hi
We create application which was used webdav method
using this we fetch mails from exchange server for a particular mail id (like xxx@uuu.com)
We fetch Inbox Mails and Sent Items folder mails and insert into two tables (sql server)
My problem is, I want relate to Inbox Mail and Sent Item Mail
If One mail is come from in my inbox
say like "New Mail.EML"
when i reply to "New Mail.EML"
it stored in sent items folder as "RE:New Mail.EML"
i want how to find relationsship between NewMail and RE:NewMail
Which Property in webdav method , to determine this relationship
Expecting Earlier answer
By
Arun
|
|
|
|
|
I have create one xml from one dataTable.
DataTable dt=new DataTabel();
.................
oleDbCommand1.CommandText = "SELECT * From ss";
adapt = new OleDbDataAdapter(oleDbCommand1);
...............
adapt.Fill(dt, "one");
dt.WriteXml("dei.xml");
the xml is like this:
<one>
<unu> string <\unu>
<\one>
<one>
<unu> double <\unu>
<\one>
<one>
<unu> float <\unu>
<\one>
i need to create :
<one>
<unu> string <\unu>
<unu> double <\unu>
<unu> float <\unu>
<\one>
-- modified at 4:54 Wednesday 14th March, 2007
|
|
|
|
|
Add this datatable to a dataset names one. Then use dataste writexml method..
I am not sure..It's a wild guess
|
|
|
|
|
no works that
|
|
|
|
|
I'm a beginner. I opened a new form and want to close old form. But I don't know how to close old form. Help me!
Thank you everybody.
|
|
|
|
|
|
You can hide the old form
Form2 form=new Form2();
this.Hide();
form.Show();
... but it is a problem if you close the form2 the program run in background
|
|
|
|
|
ya so when form2 is closed,
please use a similar piece to show any other form, from which u can proceed.
Keshav Kamat
India
|
|
|
|
|
if you want to close the application you need to use
Application.Exit();
|
|
|
|
|
Don't close the form where static void main is there. Entire application will be closed !!!!!!!!!!
|
|
|
|
|
Hello All,
While creating a database, i have to issue the following command.
CREATE DATABASE Logger1 ON PRIMARY (Name = test_data, filename ='C:\\mydb_data.mdf', size = 3, maxsize = 5, filegrowth = 10%)log on (name = mydbb_log, filename = 'C:\\mydb_log.ldf', size = 3, maxsize = 20, filegrowth = 1)
Please note that the max file size while creating the mdf file is 5MB and the max file size while creating the ldf file is 20MB.
I dont want to restrict it to a finite value.
By default when a database is created through GUI, it has an unrestricted file size.
so in the same way, can someone please tell me what should I provide as maxsize to have unrestricted growth.
any help would be useful
Keshav Kamat
India
|
|
|
|
|
Keshav V. Kamat wrote: can someone please tell me what should I provide as maxsize to have unrestricted growth
I wasn't aware that you had to supply a max size value. Just leave it out.
|
|
|
|