|
What I still can not figure out is passing a ref into the form is great for 1 way population if information. But What I need is to be able to receive a list back to the parrent replacing the list the parrent currently has with the modified list of the child.
I keep thinking I need to set up a List<string> Property on the child form. But I can not find any examples on how to set up a list<string> Property.
Please Help.
|
|
|
|
|
Don't pass controls around. Pass the data around. Use delegates to pass changes back to the main form.
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.
|
|
|
|
|
|
JollyMansArt wrote: but I am not understanding an example where I can pass List between parrent and child forms...
DON'T pass a list control between your forms. Pass the list itself ( I don't know if that's what you mean by list ). Pass it into the form, then if the form is modal, you can just access it back out with a property. If the form is modeless, a delegate is needed to tell the main form when data was changed inside the other form ( assuming this is possible )
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.
|
|
|
|
|
I am not passing a control I am passing a List<string> ABC Object which is sort of like string[].tolist<string>()
I agree with what your saying and I just thought of that to. Now I just have to remember how to do that. I have avoided interform communication methods in the past. Now it is time to figure out how to do it again. Your right though..
Encapsulating the new form in a using statement in a previous project did allow me to communicate with it from the parrent form. I just forget how to do that. I will research. Unless you have a sample. I am close in my code example i think.
|
|
|
|
|
Hi,
I assume this is about System.Net.Mail.MailMessage, which has three properties (To, Cc, Bcc) of type MailAddressCollection.
you can pass such lists just like any other object, and it does not need a ref keyword; and the receiving method can enumerate, add, remove, and perform all operations that the list supports. The one thing you cannot do is replace the list by a different list (that is the only operation that would require you to use the ref keyword).
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Partial assumption is correct.....
This is the mailmessage as to what it will go to. That part of the application I have working. I am tweaking the (to,cc,bc) before I pass the parameter to the procedure handling the list. To allow for the ability for a popup window with 2 checkbox list boxes. To allow the end user to override or add to the list of email addresses the will be used to send the autogenerated email. It was a requirement being asked in the last second.
So I need to pass the 2 list variables into the popup form, allow the form to add/delete items from the list variable for the (to,cc,bc) email addresses. Then finally pass the new list objects back to the parent, replacing the parents list variables from the list variables received from the child.
|
|
|
|
|
Here is some of the code behind what I am doing before:
private void SendEmail(string AlertType, string Subject, string MessageBody)
{
string[] MailTo;
string[] MailCC;
string MailFrom = "it@peerassistllc.com";
List<string> EmailToAddress = EmailTo(AlertType);
List<string> EmailCCAddress = EmailCC(AlertType);
if (EmailToAddress.Count > 0)
{
MailTo = EmailToAddress.ToArray<string>();
MailCC = EmailCCAddress.ToArray<string>();
}
else
{
MailTo = EmailCCAddress.ToArray<string>();
EmailCCAddress.Clear();
MailCC = EmailCCAddress.ToArray<string>();
}
string smtpHOST = txtSMTPServer.Text;
int smtpPORT = Convert.ToInt32(txtsmtpPortNumber.Text);
string smtpNETAuthUser = txtsmtpServerAuthencationUserName.Text;
string smtpNETAuthPassword = txtsmtpServerAuthencationPassword.Text;
int i = 0;
string LogMessage = "Mail From: " + MailFrom;
if (MailTo.Length > 0)
{
LogMessage += " Mail To: ";
for (i = 0; i < MailTo.Length; i++)
{
LogMessage += MailTo[i] + "; ";
}
}
if (MailCC.Count<string>() > 0)
{
LogMessage += " Mail CC: ";
for (i = 0; i < MailCC.Length; i++)
{
LogMessage += MailCC[i] + "; ";
}
}
LogMessage += " SMTP Host Server: " + txtSMTPServer.Text;
LogMessage += " SMTP Server Port: " + txtsmtpPortNumber.Text;
LogMessage += " SMTP Server UserName Authencation: " + txtsmtpServerAuthencationUserName.Text;
LogMessage += " Message Subject: " + Subject;
StandardProcedures.SQL_Log(WhatIsMyConnectionString, AlertType, LogMessage, true);
StandardProcedures.SQL_Log(WhatIsMyConnectionString, AlertType, MessageBody, true);
if (MailTo.Count<string>() == 0 & MailCC.Count<string>() == 0)
{ return; }
ConfirmEmailReceipents(ref MailTo, ref MailCC);
StandardProcedures.NET_AuthenticatedMailSend(MailFrom, MailTo, MailCC, Subject, MessageBody, smtpHOST, smtpPORT, smtpNETAuthUser, smtpNETAuthPassword);
}
modified on Tuesday, October 20, 2009 8:25 PM
|
|
|
|
|
The ConfirmEmailReceipents is the process I need to work in passing my list to the child then back to the parrent to allow for modifications. Any Suggestions...
|
|
|
|
|
Here is the Code I am trying to get to work to pass the variable to pass between the parent and child...
private void ConfirmEmailReceipents(ref List<string> EmailTo, ref List<string> EmailCC)
{
using (frmpopupEmailRecipient popupVerifyEmailRecipients = new frmpopupEmailRecipient(ref EmailTo, ref EmailCC))
{
popupVerifyEmailRecipients.ShowDialog(this);
}
using ( frmpopupEmailRecipient f2 = new frmpopupEmailRecipient())
{
if( f2.Show() == DialogResult.OK )
{
f2.toEMAIL;
f2.ccEMAIL;
int i = f2.Number1;
string s = f2.String1;
}
}
}
|
|
|
|
|
I think I might of figured out how to pass the list to the child form. By Adding a Public List<string> in the child form. WOrking on testing that But now I have a somewhat new question....
How do I have the child form return the result of Dialogbox.ok?
I have set the child form's ok and cancel button's dialog property to the ok and cancel property. But I am unsure how to pass that to the parent form.
|
|
|
|
|
JollyMansArt wrote: allow the form to add/delete items from the list variable for the (to,cc,bc) email addresses. Then finally pass the new list objects ...
That is wrong, when you add/delete to a list (which is an object) it still is the same list (i.e. the same object, the difference is it may contain some other items).
For the rest, I'm not going to study all that, it is way too much code for anything you may want to do. And AFAIK some of it will not even compile.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
I figured out finally how to pass the array to the child and back...
Parrent Form:
using (frmpopupEmailRecipient popupVerifyEmailRecipients = new frmpopupEmailRecipient())
{
popupVerifyEmailRecipients.MyEmailTo = EmailTo;
popupVerifyEmailRecipients.MyEmailCC = EmailCC;
if (popupVerifyEmailRecipients.Show() == DialogResult.OK)
{
}
EmailTo = popupVerifyEmailRecipients.MyEmailTo;
EmailCC = popupVerifyEmailRecipients.MyEmailCC;
}
Child Form:
public partial class frmpopupEmailRecipient : Form
{
public List<String> MyEmailTo;
public List<String> MyEmailCC
}
Now optionally I would like for learning instead of just closing the frm... How do I modify the child form to return a dialogresult.ok value?
|
|
|
|
|
A Control (a Form IS a Control) offers the following methods amongst others:
public void Show()
public DialogResult ShowDialog()
and the MSDN page on ShowDialog clearly explains how the return value is determined.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
hi
how to make line after 2 rows in crystal report ?
ex:
aaaaaa
bbbbbb
------------------------------------
cccccc
ddddddd
------------------------------------
(working in C#)
thank's in advance
|
|
|
|
|
You create a formula field with below code and drag drop that field into ur crystal report detail section below ur data field, I hadnt checked may be it will work..<br />
<br />
<br />
Global booleanVar flag:=true;<br />
Local stringVar print ;<br />
if flag then print :="__________________________________";<br />
flag=false;<br />
if flag=false then<br />
flag:=true;<br />
print :=""
modified on Thursday, October 22, 2009 2:27 AM
|
|
|
|
|
You create a formula field with below code and drag drop that field into ur crystal report detail section below ur data field, I hadnt checked may be it will work..
shared booleanVar flag;
if flag then
(
flag:=false;
"";
)
else
(
flag:=true;
"__________________________________" ;
);
It will work !!!!!!!!!!!!!!!!!!
|
|
|
|
|
I need to get informed about every incoming network connection in C#.
All examples I found on the web were client/server stuff.
But I don't have any clients.
I want to get notified about all incoming connections at all ports.
How does it work? Which class can I use? Are there any events?
Thanks in advance for any hints and help.
Max
|
|
|
|
|
Wild Max wrote: Which class can I use? Are there any events?
.NET doesn't have an event that handles all incoming connections. Some connections are even made without the Frameworks' knowledge!
You could dive into the Firewall API, I believe that all connections pass through there.
I are Troll
|
|
|
|
|
string message = Timetable(doc);
public string Timetable(XmlDocument xmldocument)
{
string timetableResult = "";
if (xmldocument != null)
{
Output("Processing...");
using (StreamReader sw = new StreamReader(new FileStream("out1.xml", FileMode.Open)))
{
string str = sw.ReadToEnd();
//extraction and suppose there's a string here which I want to return
}
}
}
I can't seem to return a string, the error says :Could not load file or assembly 'RS232, Version=1.24.0.0, Culture=neutral, PublicKeyToken=515d87df384dcc81' or one of its dependencies. The system cannot find the file specified.
Please help.
|
|
|
|
|
Apparently, something in the code you are not showing is depending on a class in the RS232 library and that library cannot be found.
P.S. If the component from that library is a serial port and you are on .NET 2+, you could consider switching to the built in System.IO.Ports.SerialPort class.
|
|
|
|
|
Hi
i have a simple unBound field in my report designer named 'UnboundString1'.
i want to pass value to this field froom code, but i don't know how to do that. i also create a parameterField and use this code to pass value but nothing happened :
this.customersTableAdapter.Fill(this.northwindDataSet.Customers);
ParameterField myParam = new ParameterField();
myParam.ParameterFieldName = "UnboundString1";
ParameterDiscreteValue myDiscreteValue = new ParameterDiscreteValue();
myDiscreteValue.Value = "USA";
myParam.CurrentValues.Add(myDiscreteValue);
this.crystalReportViewer1.ParameterFieldInfo.Add(myParam);
this.CustomersReport1.SetDataSource((DataTable)this.northwindDataSet.Customers);
this.CustomersReport1.Refresh();
this.crystalReportViewer1.RefreshReport();
how to workaround this problem ?
|
|
|
|
|
Hi
i have a datagridview in a form that have a ComboBox column.
i want to send a value from an other form to datagridview combo box column.
i connected the combo box column to a table that show a member in Display Member
and return the Value Member but i dont know how to get the value in value member.
actually i lookin for something like SelectedValue in ComboBox Class.
how can i it?
thanks
|
|
|
|
|
The following code will get the value. You can ignore the fact that it is a DataGridViewComboBoxColumn for your purpose.
DataGridViewRow currRow = this.dataGridView1.CurrentRow;
this.txtValue.Text = currRow.Cells["CBColumn"].Value.ToString();
DataGridViewRow anyRow = this.dataGridView1.Rows[2];
this.txtValue.Text = anyRow.Cells["CBColumn"].Value.ToString();
DataGridViewCell currCell = this.dataGridView1.CurrentCell;
this.txtValue.Text = currCell.Value.ToString();
I have split the processing into two lines, and I would probably do this anyway because it is easier to understand. However, you could do it in one line, like this: (I have only shown the first one although you could do the same for all three)
this.txtValue.Text = this.dataGridView1.CurrentRow.Cells["CBColumn"].Value.ToString();
**NOTE**
'CBColumn' is the Name I have given to my DataGridViewComboBoxColumn , the Name property, not the HeaderText
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.”
|
|
|
|
|
Hi group,
I'm converting a large old C++ program to C#. It has lots and lots and lots of istream/ostream io. Is there an equivalent io capability in C#? Any suggestions on the most efficient way to do this.
Thanks /Mike
|
|
|
|