|
I do not see where this has anything to do with c#.
You may get lucky and receive a good answer, but I would have thought that this question really belongs in the General Database forum.
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.”
|
|
|
|
|
Hey budyies i wanted to access(insert datas in to) a listview item in one of my other forms ........... while the form that contains the listview is running(lets say it FormListView ) and the other form is still running @ the same time(lets say FormSender ) ......... I wanted to read a data from the listview in the FormSender and send it back to the FormListView ......... even if I make the Modifier Property of the FormListView as Public I cant call it like this from the FormSender
FormListView.listView1.Items.add("xxxx");
but I can access variables that are declared like this ....
Public static string x;
I can access by writing this code with out creating its instance
FormListView.x="xxxxx";
Please help me.
Thank you
|
|
|
|
|
I'd create public or internal Add and Read methods on the FormListView (keeping the ListView 's access modifier private).
When you create the instance, hold it in a field
public class FormSender
{
FormListView formListView;
void MethodThatInstanciatesFormListView()
{
formListView = new FormListView();
formListView.Show();
}
void ReadData()
{
List<Data> data = formListView.Read();
}
void AddData(Data data)
{
formListView.Add(data);
}
}
public class FormListView
{
public List<Data> Read()
{
}
public void Add(Data data)
{
}
}
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)
|
|
|
|
|
DaveyM69 wrote: List data
what does the "List " and "<Data>" refers to....sry I have no idea abt that ... but I will try it .... and 1 more question.
DaveyM69 wrote: void AddData(Data data)
what data type is this "Data "
Thank you for ur help.
|
|
|
|
|
matiIsGreat wrote: what data type is this "Data"
Change it for whatever class/struct you are using to hold the data you are wanting to pass to formListView
matiIsGreat wrote: List
You don't have to use a List<T> , but it's a useful way of having a collection of whatever T is in one object. Clickety[^]
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)
|
|
|
|
|
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.”
|
|
|
|