|
Luc Pattyn wrote: hope your PC and power company will run that long without failure...
Well, you could build some protection into the program. If it saves the string to a temporary file every now and then, it could continue from the last save point in case of a failure.
---
single minded; short sighted; long gone;
|
|
|
|
|
On the other hand, there may be better ways[^] to spend idle CPU cycles...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
TextBox tr2 = new TextBox();
tr2.Location = new Point(400, 163);
this.Controls.Add(tr2);
TextBox tr1 = new TextBox();
tr1.Location = new Point(495, 163);
this.Controls.Add(tr1);
textBox1.Text = Convert.ToInt32(tr2.Text) * Convert.ToInt32(tr1.Text) ;
}
where is the error that??
|
|
|
|
|
The error comes clearly from the last line. You try to convert the text of newly created TextBoxes to a number. As you haven't assigned anything to them they will contain an empty string. What value would you expect them to have?!?
|
|
|
|
|
Where do you set tr1.Text and tr2.Text? Based on the code you provided, they will both be an empty string.
|
|
|
|
|
Hello,
I'm trying to make a C# program that, in part, sends and receives emails. I'm using Gmail as the account, and can send emails from this program that would show as if I'd sent it from my Gmail account because it sends a command to Gmail containing my name and password, the email itself, who it goes to, etc.
That's fine, but the other half of the transfer is what's got me stumped--how to get the emails off that same Gmail account and show them on the screen.
Does anybody have any experience with this that can guide me in the right direction?
Thanks for your time,
Michael Fritzius
|
|
|
|
|
You need to use POP3 or IMAP protocols. Check out here[^] and here[^]. You will also need to enable POP3/IMAP access in your gmail account (through the gmail interface under settings).
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thanks! I'm glad to see that one of those links was visited already so I guess I was on the right track. Those links were a ton of help.
Thanks again!
Michael Fritzius
|
|
|
|
|
Hi mates...i try to find a way to creating 2 or more texbox with 1 button for example if the user click the button i wanna create 2 or more textbox help plssss.
|
|
|
|
|
Write the following code in the event handler for the button:
TextBox textBox1 = new TextBox();
textBox1.Location = new Point(10, 10);
TextBox textBox2 = new TextBox();
textBox1.Location = new Point(10, 20);
this.Controls.Add(textBox1);
this.Controls.Add(textBox2);
That's it. You can of course set the other properties for the textboxes as well.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
tr.text=convert.tostring(convert.toint32 (textbox1) * convert.toint32 (textbox2))
where is the problem in there can u help me??,
|
|
|
|
|
and why its crate texboxes together i write different coordinates but they r together
|
|
|
|
|
You can't convert a textbox to a number. You want to use textbox1.Text. Also, use int.TryParse, so it doesn't blow up if it can't convert.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
private void createTextBox()
{
}
private void button1_Click(object sender, EventArgs e)
{
createTextBox();
createTextBox();
}
|
|
|
|
|
Maybe you should do this:
private void createTextBox(string name)
{
TextBox name = new TextBox();
}
private void button1_Click(object sender, EventArgs e)
{
createTextBox(box1);
createTextBox(box2);
} Otherwise they probably would cause an exception if two textboxes are created with the same names.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Hi!
I am trying to run a timer in my Form.
The form has a function that is being called from the timer handler but i have a problem.
this is the code:
private static void TimerHandler(Object myObject, EventArgs myEventArgs)
{
starttime.Stop();
starttime.Enabled = false;
Form1_Main();
}
if i use the static on the Hnaler i get this error:
Error 1 An object reference is required for the nonstatic field, method, or property 'Update_Installer.Form1.Form1_Main()' C:\Documents and Settings\Yossi_Tubis\My Documents\Visual Studio 2005\Projects\Update_Installer\Update_Installer\Update_Installer\Form1.cs 124 13 Update_Installer
if i do not use it i get this:
private void TimerHandler(Object myObject, EventArgs myEventArgs)
{
starttime.Stop();
starttime.Enabled = false;
Form1_Main();
}
Error:
Error 1 An object reference is required for the nonstatic field, method, or property 'Update_Installer.Form1.TimerHandler(object, System.EventArgs)' C:\Documents and Settings\Yossi_Tubis\My Documents\Visual Studio 2005\Projects\Update_Installer\Update_Installer\Update_Installer\Form1.cs 112 31 Update_Installer
The function is in the general Form.
What to do?
Thanks
|
|
|
|
|
ytubis wrote: Form1_Main();
That 2nd error you get - what line of code is the error occurring on? My bet is you have some static timer and you're telling it to send it's Tick event notification to a non-static method.
To solve this, just don't make the timer static, don't make TimerHandler static, and don't make Form1_Main static. Don't make anything static unless there's a specific reason to do so (e.g. if it doesn't need to use any instance members)
|
|
|
|
|
Hi,
I am guessing you are working on an app without a user interface, and are trying to run
everything from your static Main method and feel a need to have everything static then.
The easy solution to that is to immediately create an
object of a new class and make it run; then nothing needs to be static except for
the main method. Example:
static Main(...) {
Test test=new Test();
test.Run();
}
class Test {
Timer timer;
public Test() {
timer=new Timer();
timer.Tick+=new EventArgs(tickHandler);
}
public void Run() {
...
}
public void tickHandler(...) {
...
}
}
BTW: you can put your static Main method inside the Test class if you want to.
It does not need a separate file or class.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hi friends..
my application (.exe) is running fine on my PC for user Administrator. but when i run the same application for another user (Restriced User Account) on the same PC, it's running the application but upon accessing the registry throguh the program code raising security exception.
"requested registry access is not allowded"
how do i configure .Net Framework Configuration tools in order to run my application (accessing registry throguh program code )
for a restricted user account. i dont want to change the level of
user account.
stephen
|
|
|
|
|
Stephen, applications generally should not require admin privileges to run. You are allowed to access certain registry keys -- would it be feasible to modify your application code to write to the registry in an allowed registry key hive? (e.g. don't write to HKLM, but instead write to HKCU)?
|
|
|
|
|
hi Judah Himango...
thank you for your reply.. it helped me to solve my problem.
now i understood the concept and it works fine with HKCU hive.
stephen
|
|
|
|
|
Hi all,
m new to C# programming.Is there any method by which we can explicitly stop addition of new item to a combo box at runtime?its urgent!!!!causing lot of problem....I'll have 2 handle exception if not stopped properly.please help.
dCodeProvider
(i'll provide 'em later;))
|
|
|
|
|
dCodeProvider wrote: Is there any method by which we can explicitly stop addition of new item to a combo box at runtime?
Yes, you simply don't call the Items.Add method. If you want any further explanation then you'll have to provide some code to feed us.
|
|
|
|
|
dCodeProvider wrote: its urgent!!!!
No, it's not. You're not paying anyone for support, so we volunteers will get to it when we can, not when you demand.
dCodeProvider wrote: causing lot of problem....I'll have 2 handle exception if not stopped properly
Don't add it then. There's no way to stop a call to someComboBox.Items.Add() . The solution is easy - don't add the item in the first place!
|
|
|
|
|
Hi All
Am developing an inventory package in C# 2005. in this customer needs printout of sales in preprinted stationary. right now am following it this way.
On Clicking the grid and print button is selected am writing it to a TEXT file named SALESPRINT.TXT.
AM HAVING PROBLEM FROM THIS PART, AM ABLE TO WRITE TO A TEXT FILE BUT THERE IS ALIGNMENT PROBLEMS. following is the format of the preprinted stationary.
INV DATE xxxxxxxxxx INV NO xxxxxxxxxxxx PAGE NO xxxxx
CUSOTMER ADDRESS1 xxxxxxxxxxxxxxxxx
CUSOTMER ADDRESS2 xxxxxxxxxxxxxxxxx
SL NO SHORT CODE ITEM NAME QTY RATE TOTAL
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
xx xxxxxx xxxxxxxxxxxxxxxxxxx 10 12.25 122.5
_______________________________________________________________________________
TOTAL xxxxx
_______________________________________________________________________________
DISCOUNT xxxxx
_______________________________________________________________________________
GT xxxxx
so right now am using string.PadRight & string.PadLeft to specify the positions of contents in the text file. but am finding it difficult to do it. customer is using Dot matrix printer & preprinted continuous sheets for printing this.
So to do this am i doing the right thing and am i on right track ????
Please guide to finish this, if anyone knows how to give line skipping in dot matrix printer pl z tell me how to do
Thanks in Advance
Freelancer
-- modified at 16:01 Thursday 27th September, 2007
|
|
|
|