|
The only sane way to do this, is to set up delegates so that the code that decides the form needs filling, can call a method in the form to fill it with data.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Even if i worked simple applications on c# 4 a year .... i didnt use delegates .... so i have no idea abt them ......... so can u show me sth hw to work on ma problem .
Thank you
|
|
|
|
|
two remarks on top of the fine answers you've got:
1. forms don't "run", they exist, and they may or may not be visible, have focus, etc.
2. "static" seldom is the solution; it is useful to create variables that exist only once per class instead of once per instance, e.g. when a class wants to count how many instances got created. Nothing else.
|
|
|
|
|
I am using the followijg code to send email trough my Gmail account but I am having two problems, first it's taking long time to send the email and second the From is showing as my Gmail account not the user email specefied in the txtEmail
private void btnSend_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
txtEmail.Enabled = false;
txtMessage.Enabled = false;
btnSend.Enabled = false;
btnClose.Enabled = false;
if (radioSuggestion.Checked == true)
email_subject = "Suggestion from (My System) user";
else if (radioBug.Checked == true)
email_subject = "Bug Reported by (My System) user";
else
email_subject = "Email from (My System) user";
if (SendMail("myGmailAccount@gmail.com", "xxxxxxxxx", txtEmail.Text, "myHotMailAccount@hotmail.com", email_subject, txtMessage.Text))
{
MessageBox.Show("Message Sent.", "Email", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Cursor = Cursors.Default;
this.Close();
}
else
{
MessageBox.Show("unable to send your email!!", "Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtEmail.Enabled = true;
txtMessage.Enabled = true;
btnSend.Enabled = true;
btnClose.Enabled = true;
this.Cursor = Cursors.Default;
return;
}
}
public static bool SendMail(string gMailAccount, string password, string from, string to, string subject, string message)
{
try
{
NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(from);
msg.To.Add(new MailAddress(to));
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
return true;
}
catch (Exception)
{
return false;
}
}
modified on Saturday, September 5, 2009 2:56 PM
|
|
|
|
|
Hey budy .... even if i had no answer 4 u please make ur code more stylish so that others read it and give an answer ............ use code block
|
|
|
|
|
noted..
waiting for a reply..
|
|
|
|
|
hope u r now getting ideas..... c z difference
Good Luck
|
|
|
|
|
matiIsGreat wrote: hope u r now getting ideas..... c z difference
Please use proper words in your answers. "u r" means nothing, similarly "c z" could be written by a monkey. If you expect the questioners to put their questions in clear English then the least you can do is answer in a similar vein! Try and act as if you are at least aspiring to professionalism.
|
|
|
|
|
Thanks for reformatting your code. The change in the From field is probably because Google's SMTP server is changing the email headers mid-stream. The delay could be almost anywhere. My guess is that you're trying to send a very large email. The SmtpClient.SendAsync might help you with that problem.
|
|
|
|
|
I am just sending :
this is a test email
|
|
|
|
|
|
Hi
I was wondering how I can implement this function in c #
There are 2 variables, x & y:
(X^2)(4sinY)
|
|
|
|
|
You can do it in the normal way:
double Z = (X * X) * (4 * Math.Sin(Y));
|
|
|
|
|
FYI: The '^' operator is Bitwise XOR in C#.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Further FYI: The Math.Pow operation raises something to a power.
|
|
|
|
|
Extended Further FYI: The Math.Ker method reinforces the Math.Pow method.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
FYI^3
... by using logarithmic and exponential functions, making it rather slow and slightly inaccurate for a simple square or cube or square root.
|
|
|
|
|
While you're at it you can also try to manually calculate Taylor series approximations to several decimal places to cut down on processing time? lol
|
|
|
|
|
I am trying to access checked Items in a checkedListbox from another method.Problem is, using "Selecteditem" and "SelectedIndex" does not work, it appears as if there aren't any items selected from the list. is there any other way I can read from the CheckedBoxList list or What am i doing wrong? Please help
|
|
|
|
|
Without seeing your code it is not easy to offer any suggestion. Normally just using myCheckedListBox.SelectedIndex should work.
Please post the code where you are trying to do it, so that people can try to help you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Is this WinForms? If so, are you getting confused between SelectedItems and CheckedItems?
CheckedListBox.CheckedItemCollection checkedItems = checkedListBox.CheckedItems;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Good spot!!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Lets name the checklistbox as table list.whenever an item is checked or unchecked just add them to a data table(_selectedTables).
<br />
private void tableList_ItemCheck(object sender, ItemCheckEventArgs e)<br />
{ <br />
string names = tableList.GetItemText(tableList.Items[e.Index]);<br />
<br />
CheckState currentState=e.NewValue;<br />
<br />
if (currentState.ToString() == "Checked")<br />
{<br />
DataRow newRow = _selectedTables.NewRow();<br />
_selectedTables.Rows.Add(newRow);<br />
newRow["Table"] = names;<br />
}<br />
else<br />
{<br />
DataRow[] dr = _selectedTables.Select("Table = '" + names + "'");<br />
if (dr.Length > 0)<br />
_selectedTables.Rows.Remove(dr[0]);<br />
}<br />
}<br />
And then use this method to retrieve the selection
public DataTable ReturnSelectedTables<br />
{<br />
get<br />
{<br />
return _selectedTables;<br />
}<br />
}
Hope this helps you.
|
|
|
|
|
Hi All
can anyone help me for searching in phone book? I use text file for saving data.
I want to find all names that contains the input character. I dont now how do it.
pleas give me a solution.
|
|
|
|
|
First thing you will have to do is to read the data from the file. You may want to read line by line looking for the characters in question. Alternatively you could read the entire file into some sort of List/Array/Dataset etc and then use the methods of those objects to search. Take a look at the foregoing classes to get some ideas of what is possible.
|
|
|
|