|
'all things is all right .I THINK U Assign n as date and here u declare string.so it might get error.
'string d = form1_.n;
' used like this
datetime n = form1.n;
'& u used from1 is the name of form right?
|
|
|
|
|
datetime n = form1.n;
-- Not Working:error on 'n'.
Nekshan.
|
|
|
|
|
I see three errors in your code.
1. You have declared the reference form1_ as a reference to a Form object, not a form1 object. Therefore you only have access to the members of the base class, none of the members of the inherited class.
2. You are creating a completely new instance of form1 , that means that it's separate from the instance that already exists. This in turn means that the n member has not been set for that instance.
3. You are executing an insert query and expect it to return data. The result from an insert query is empty, so the ExecuteScalar method will return null. This will be converted to DateTime.MinValue by the Convert.ToDateTime call.
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Thanx Sandeep.
The project u suggested is really nice.
Nekshan.
|
|
|
|
|
My Pleasure
<l>Thanks and Regards
Sandeep
|
|
|
|
|
Hi,
I'm writing a LoadGenerator application, in which for a specific period of time
certain no.of Threads are created and executes simultaneously..
That i call as RampUp threads.
After sleeping for a sustain period (10secs) of time.. I want to RampDown threads, that is i want to kill the threads one by one..
I have defined an ArrayList object alThreads to maintain the Threads list..
RampUp() method
public void RampUp()
{
for(int i=0; i<10; i++)
{
Thread thread = new Thread(ExecuteSingleThread);
thread.Start();
if(alThread.Contains(thread) == false)
{
alThreads.Add(thread);
}
Thread.Sleep(5000);
}
}
The below code kills the thread every five second..
RampDown() method
public void RampDown()
{
for(int i=0;i<alThreads.Count;i++)
{
Thread thread = (Thread)alThreads[i];
if(thread.IsAlive)
thread.Abort();
Thread.Sleep(5000);
}
}
Now the problem is after killing the first thread, all the remaining threads
doesn't executes the code inside it..
Please help me..
regards,
nas
|
|
|
|
|
Hello,
I am trying to create an Windows Application using Visual C# and I am having the following problem.
I have a second WinForm (Form2) which is used for login. I would like to send the login information back to main window (Form1) in order to display it there. Currently, I am able to do so but I am using the following code:
private void button1_Click(object sender, System.EventArgs e)
{
Form2 frm=new Form2();
frm._textBox=_textBox1;
frm.Show();
}
This does the job but it opens a NEW window. Is there anyway that I can simply refresh my existent window rather opening a new one?
Thank you.
Khoramdin
|
|
|
|
|
|
Hello Martin,
Thanx for the message. It was a great help. I managed to get this going but I have one question.
I followed the article and managed to pass only ONE variable between Parent and Childs. I am not sure if there is a way to pass more than one variable or I am missing something.
Thanx again for your help, mate.
Khoramdin
|
|
|
|
|
Hello,
I'm glad I could help!
Khoramdin wrote: I am not sure if there is a way to pass more than one variable or I am missing something
You could:
)work with more than one property
)use a struct
)use a class
)use a collection, like Hashtable or ArrayList or ...
All the best,
Martin
|
|
|
|
|
Look at the ShowDialog method of a form for opening a Modal Dialog
<br />
using (MyForm myForm = new MyForm())<br />
{<br />
myForm.ShowDialog();<br />
}<br />
...and overloading the form constructor and/or return to provide the data you want.
Rhys
ELYSIUM, n. An imaginary delightful country which the ancients foolishly believed to be inhabited by the spirits of the good. This ridiculous and mischievous fable was swept off the face of the earth by the early Christians -- may their souls be happy in Heaven!
Ambrose Bierce (1842 - 1914)
Behind every argument is someone's ignorance.
Louis D. Brandeis (1856 - 1941)
|
|
|
|
|
private void logout_Click(object sender, EventArgs e)
{
conn.Open();
string strQury = "";
strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'";
SqlCommand cm = new SqlCommand(strQury, conn);
int n = Convert.ToInt32(cm.ExecuteScalar());
}
I have written this code in form1.cs and i need to write it there only on 'logout_click'.
Now i want to use this 'int n' in a function in form2.cs of same project:
funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n);
but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs.
How can i declare this 'int n' of form1 in form2?
How can i do this?
thanx.
nekshan.
-- modified at 1:57 Tuesday 20th February, 2007
|
|
|
|
|
'form1
' define this n globally on top of form1
Public n As Integer
' form2
' create objec to from1 in from2
Dim f1 As New Form1
' used like
string s = f1.n
'this declaration is vb convert it to c# ok.
|
|
|
|
|
In form1,i defined it like :
namespace WindowsApplication1
{
public partial class form1 : Form
{
public DateTime n;
SqlConnection conn = new SqlConnection("Data Source=PROGRAMER;Initial Catalog=....");
.....
}
In form2,i made object of form1:
System.Windows.Forms.Form form1_ = new form1();
string d = form1_.n;
-- BUT it is giving error on 'n' here, 'n' doesnot come on click of'.' after form1_
I have used it like this in form1:
private void button1_Click(object sender, EventArgs e)
{
conn.Open();
string strQury = "";
strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'";
SqlCommand cm = new SqlCommand(strQury, conn);
n = Convert.ToDateTime(cm.ExecuteScalar());
}
Is my global declaration of 'n' still not proper?
Thank You.
Nekshan.
-- modified at 2:51 Tuesday 20th February, 2007
|
|
|
|
|
Hi
Use Query string or you can put this varaible in the session and get it from the session on next page
<l>Thanks and Regards
Sandeep
|
|
|
|
|
session? i m doing windows programming.
can i use session in windows programming? i dont think so..
if can... how?
Thank You.
nekshan.
|
|
|
|
|
Sorry Boss
You should mension that
<l>Thanks and Regards
Sandeep
|
|
|
|
|
Store the value in a hidden html field.
And user server.transfer to go to other form
and in form2 use the request object to get the value of hidden field from form1
Nana
|
|
|
|
|
i m doing windows programming.
|
|
|
|
|
ya wind prog code is sent u
|
|
|
|
|
Declare a var in Form1 and not in method.
public static int n;
set the value in form1's method.
Now in form2 access it as Form1.n u will get the value.
Nana
|
|
|
|
|
you can set the variable up as a public static property of some class. This isn't the best technique as it is very similar to having a global variable.
You could set a property on form2 or pass the value of n into form2 in its constructor, I would rather do one of these depending on how your application is coded.
Russell
|
|
|
|
|
hi,
how to open a new form when ever a user clicks on e.g(compile button).
The window should pop up at bottom of main window like error window.
pls help me
Thank you
With Regards
prasad
|
|
|
|
|
Use window.open on click on button.
in the method add feature to open it at bottom.
Nana
|
|
|
|