|
Im having trouble with a Windows application .......
When i run the Application in windows XP NO PROBLEMS
But when i run the APPLICATION ON WINDOWS2000 SP4 i dont get the same results as in XP
although all the nessecary Prerequisites are all installed (MDAC2.8,.NET Framework 2,Windows Installer 3)
The Application Opens up an excel file and read the data to a dataset and then copies one column that a user selects to an arraylist, then Open another excel file and also read the data to the dataset and copies the selected cloumn to another ArrayList and then compares the Arraylist from the first file with the arraylist from the second file and REPORTS in which rows there have been match's ........
so when i run the Application in the XP i GET about 342 Match's but in Windows2000 I GET ONLY 10 MATCHS
i dont know how the Application is Affected by the OS And HOW TO SOLVE THIS !!!!!!!!!
LIVE TO THE BEST WHILE GATHERING KNOWLEDGE AND LOVE IN LIFE
|
|
|
|
|
|
SAME EXCEL files same program diffrent OS's!!!!
|
|
|
|
|
CAPS LOCK IS SO F***ING ANNOYING, REMEMBER HARDLY ANYONE WILL HELP YOU WHEN YOU SHOUT LIKE MAD
modified 12-Sep-18 21:01pm.
|
|
|
|
|
sir i have to make a gui application in c# that will run a cosole application and will give inputcommands and receive output from that console application. i invoke the cmd.exe in c# using system.diagnostic.process.start() function now i need do pass commands to my process as well as receive output.
please give solution to it and list related namespaces to be used.
sherry; email : shaheryar011@gmail.com
-- modified at 5:32 Tuesday 27th December, 2005
|
|
|
|
|
following is the default procedure for calling event
this.button1.Click += new System.EventHandler(this.button1_Click);
private void button1_Click(object sender, System.EventArgs e)
{
}
Now what i want the following
this.button1.Click += new System.EventHandler(this.demo);
private int demo()
{
MessageBox.Show("Called");
return;
}
demo is the function which i have to called. which is returning value.
but when i do with above code it gives me error " does not match with delegate"
how can i call my own function instead of system defined. and how can i handle the returning value
Amit Grover
CDAC R&D
|
|
|
|
|
Events by convention take two parameters, object sender and System.EventArgs e . The sender tells you from where the event has been fired, and the eventargs is a reference to a class where you can define your entry and exit parameters for the event. You can derive a new class from EventArgs for this where necessary, although in your example you're in the realm where everything has been defined for you, so you really shouldn't be doing this.
Alternatively, if you want to break with convention and best practices you can define your own events which don't follow this pattern, but you won't be able to attach these to things like the button click event, as it expects this sender/arguments prototype.
You can do this by defining a delegate which describes your callback prototype, and then creating an event of type said delegate.
I'd stick with convention if I were you...
Regards,
Rob Philpott.
|
|
|
|
|
Alternatively you can do:
this.button1.Click += new System.EventHandler(this.button1_Click);
private void button1_Click(object sender, System.EventArgs e)
{
demo();
}
private int demo()
{
MessageBox.Show("Called");
return;
}
//OR
this.button1.Click += new System.EventHandler(this.button1_Click);
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Called");
return;
}
-- Don't worry about the world coming to an end today. It's already tomorrow in Australia --
|
|
|
|
|
I have an application with a form and a class.
The form has a textbox, and it creates an instance of the class when it loads.
In the class there is a thread that, let's say, calculates a number, and wants to display this number in the textbox on the form.
How can I do this?
(I can't seem to get access to the textbox from the class)
|
|
|
|
|
Your textbox belongs to a class as well, the form class and by default this textbox has private access so you can't get at it.
Take a step back though, what you are trying to do here is tightly couple the GUI to the logic. You end up with a calculation class which can only be used in conjunction with a particular form. You should call out from the form class to the calculation class, collect the answer in the form class and then assign it to the textbox. The calculation class should be made as reusable as possible and not have a clue about the GUI of the application it is to be used in.
You need to be particularly careful if using worker threads - these should not access GUI components without a thread switch provided by BeginInvoke .
Regards,
Rob Philpott.
|
|
|
|
|
Ok, about not calling a certain form in the class, I agree with you, but I have a problem with "collecting the answer in the form class and then assigning it to the textbox" as you said, because I have to change the text in the textbox everytime the thread calculates a new value for the number. how can I do this in the form? how can I know when to collect the number?
about the last sentence you wrote:
"You need to be particularly careful if using worker threads - these should not access GUI components without a thread switch provided by BeginInvoke."
I didn't understand what u meant.
I'm fairly new to C#, and to threads in particular..
if u could explain further..
The thread I wrote is like this (it actually reads data and then does some calculation)
public class classA
{
Thread ReadThreadProc;
classA() //constructor
{
ReadThreadProc = new Thread(new ThreadStart(OpticsReadThread));
ReadThreadProc.Name = "ReadThread";
ReadThreadProc.IsBackground = true;
ReadThreadProc.Start();
}
private void ReadThread()
{
while (true)
{
Receive();
}
}
public void Receive()
{
//function that handles what the thread reads...
}
public void CloseThread()
{
ReadThreadProc.Abort();
}
}
I don't know if this is called a worker thread...
hope I was clear. if u need any further explanations, let me know.
I'm really stuck here...
thanks ))
|
|
|
|
|
Hi again,
Yes, that's a worker thread you are creating there. A worker thread is a thread which doesn't contain a message pump (ie. GUI message handler). It's not a simple subject but the golden rule is that only the thread which creates a control should access it. Your main thread creates the textbox, and only it should access it, so you need to do a BeginInvoke to switch from the worker thread to the main thread to do the update.
Firstly though, try to decouple the calculations class from the GUI completely. A nice way to do this would be instantiate your calculations class and register the forms interest in an update event it exposes. You can then get the calculations class to run its thread and it will notify the form class via events when it needs to update the GUI. In the forms event handler we will have our BeginInvoke thread switch to ensure the correct thread does the update and the job's a goodun.
Incidentally, I'm not sure about the use of Abort for terminating a thread - I think that's bad but need to check the correct way to do it.
There are some tricky concepts here - thread switching/delegates/events etc., so if I've lost you completely let me know and I'll bosh you together a sample app...
Regards,
Rob Philpott.
|
|
|
|
|
I don't undersatnd what u meant by: "In the forms event handler we will have our BeginInvoke thread switch to ensure the correct thread does the update and the job's a goodun."
what is BeginInvoke thread switch?
can u please write an example of code?
about the termination of the thread - I went by an example I found, and I'm also not sure it's the best way to end a thread. If u have any suggestions, they will be welcomed...
thanks
|
|
|
|
|
Your app will have two threads in it - the primary thread which creates your form and control and then spends most of its life idling but handles button clicks and the like, and the worker thread which churns away in the background.
This worker thread wants to update the GUI but we can't allow this - this must be done by the primary thread. If you do the update on worker thread all will seem well and then one day your program will hang and your life goes down the toilet. This is where BeginInvoke comes in, the worker thread calls this to get the primary thread to do the update for it. I'm not 100% on this but I think it does a PostMessage under the covers.
I'll put a sample together and email it to you. Are you using VS2003 or VS2005? Incidentally, I understand that VS2005 complains if you attempt to update the GUI from the worker thread - this is not the case in 2003.
Regards,
Rob Philpott.
|
|
|
|
|
I'm using VS2005 beta version..
|
|
|
|
|
Will for just an easy way to get access to the text box in simple thoughts
you just have to go to the Form Designer Code And Then change
private System.Windows.Forms.TextBox textBox1;
to
public static System.Windows.Forms.TextBox textBox1;
and also change all
this.textBox1....etc
to
Form1.textBox1....etc
and then you can control the textbox from the class or any where...;D
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
class testing_textbxx
{
int a;
public void change()
{
Form1.textBox1.Text = "This is a good way for Solving";
}
}
|
|
|
|
|
You could do this, but I'd argue it's not the way forward. It defeats the purpose of encapsulation and leads to hideously structured code. And you can't control the textbox from anywhere - doing this from a worker thread as in this example is positively dangerous.
Regards,
Rob Philpott.
|
|
|
|
|
1, do ne one know how to avoid the access prompt that come up when you access emails through code.
2, it prompt several times when u access different Public Properties of MailItemClass's object.
3, How to access the Mail Profiles and Accounts. as I want to send an email through ne particular email account.
Thanks
|
|
|
|
|
The security message box pops up due to the security mechanism in the Outlook object model. One of the ways to circumvent this is to use this Outlook Redemption library here is the link:
http://www.dimastr.com/redemption/
Here is some more info on Outlook security.
http://www.outlookcode.com/d/sec.htm
Also you will find more information about Outlook programing on outlookcode.com
Hope this helps.
|
|
|
|
|
Printing seems to be a pain in .NET. I am currently working on a Word Processor in C# that I started a while back to learn C#. The application is pretty much done except for printing. I can't seem to get formatting to show up in printing or previewing. Is it possible to have a WYSIWYG printing? Wanted to finish it while I'm on Christmas break.
Thanks
|
|
|
|
|
Try this:
http://www.c-sharpcorner.com/winforms/texteditor.asp
http://www.ondotnet.com/pub/a/dotnet/2002/06/24/printing.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingprintingprintdocumentclassprinttopic.asp
"Don't worry about the world coming to an end today. It's already tomorrow in Australia"
|
|
|
|
|
|
Hi,
I want the details of IE window as soon as IE window is opened either by double clicking from Desktop icon or from Start menu. So is there any event which gets fired when the IE window is opened which I can capture in my program. My program will be a Windows service written in C#.
Please let me know how it can be done.
Thanks in advance.
Sunil
|
|
|
|
|
Here is a function I wrote that checks if Internet Exlplorer is running and if it is, the function returns true. You can put this function in a function of a Timer class that executes the IsExplorerRunning function at a specified interval - therefore checking every let's say 100 milliseconds. Let me know if you have any questions.
Make sure you include System.Diagnostics:
using System.Diagnostics;//put at the beginning
//put function in class
private bool IsExplorerRunning()
{
Process[] myProcess = Process.GetProcesses();
int i = 0;
try
{
while (myProcess[i] != null)
{
if (myProcess[i].ProcessName.ToUpper() == "IEXPLORE")
{
int i2 = 0;
try
{
while (myProcess[i2] != null)
{
myProcess[i2].Close();
i2 += 1;
}
}
catch { }
return true;
}
i += 1;
}
}
catch { }
int i3 = 0;
try
{
while (myProcess[i3] != null)
{
myProcess[i3].Close();
i3 += 1;
}
}
catch { }
return false;
}
|
|
|
|
|
Hi,
Thanks for your solution. But won't it slow down the system running this code every 100 milliseconds?
Regards,
Sunil
|
|
|
|