|
Hello,
I don't think that it's the most elegant solution, but try this:
SendKeys.Send("{TAB}");
This will send a keyboard input (in this case TabKey) to the focused Control.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Take a look at the Control.SelectNextControl method.
"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
|
|
|
|
|
I am working on the C# code.
I am presently using the 'this.Close()' when the user clicks on the 'Done' button on the form, but my application is crashing at this point.
Is there someway by which I can close the form other than 'this.Close()' ?
I tried using 'this.Dispose()', but it closes the application at some other point.
Can you please help
|
|
|
|
|
Hello,
ArchaBhandare wrote: but my application is crashing at this point
What happens? (Which exception is thrown?)
Are there some cyclic handlers (for example timers) programmed in your forms code?
All the best,
Martin
|
|
|
|
|
The Exception message is as follows
"An unhandled exception of the type 'System.MissingMethodException' occurred in System.Windows.Forms.dll"
I tried replacing the dll file, but it still crashes at 'this.Close()'. I have upgraded by device. Still the issue occurs.
The best thing is that it works for all other forms, only for this particular form, the 'this.Close()' gives an exception.
If I comment out this line of code and have a this.Dispose() instead, the application does to crash but closes automatically at some other point.
|
|
|
|
|
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 hav 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:48 Tuesday 20th February, 2007
|
|
|
|
|
'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
|
|
|
|