|
use delegation:
in form1 create textbox and put:
public delegate void dd(string s);
public static dd d;
and put (d=new dd(write);) in public Form1()
then write method (write):
privet void write(string s)
{
textbox1.text=s;
}
in form2 create button and textbox then in click event put:
Form1.d(textbox1);
modified on Wednesday, January 20, 2010 6:53 PM
|
|
|
|
|
There are three obvious ways if Form1 is the parent.
1. Form1 sets a property in Form2 (as suggested above)
2. Form1 calls a method in Form2
3. Form2 raises a custom DataRequest event with custom EventArgs . Form1 subscribes to this and fills the event args accordingly when it handles the event.
If Form2 is the parent form then a DataChanged event in Form1 and a suitable handler in Form2 is the way to go.
If the hierachy is different, then a combination of the above up and down the hierachy will work. If that gets too complex then a separate manager class that routes events between the class instances can be useful.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi
I need to validate the email addresses to check if they are existing or not.
I used the following code to check first for the validation of domain but it failed with the following exception : A connection attempt failed because the connected party did not properly respond after a certain period of time, or established connection failed because conencted host has failed to respond 209.85.135.17:25
Here I used 25 port but is that port valid or i have to use someother port.
string address = "test@g.com";
string[] host = (address.Split('@'));
string hostname = host[1];
IPHostEntry IPhst = Dns.Resolve(hostname);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s= new Socket(endPt.AddressFamily,
SocketType.Stream,ProtocolType.Tcp);
s.Connect(endPt);
Can anyone please help me. Any Ideas please!! I need it urgently.
Thanks in advance,
--
http://ashakthi.blogspot.com
http://kids-articles.blogspot.com
|
|
|
|
|
In my country many providers block port 25 to reduce spam. tried another?
|
|
|
|
|
This will also depend on the firewall settings on your network setting etc.
Now...bring me that horizon. And really bad eggs...Drink up me hearties, YO HO!
|
|
|
|
|
|
Hi men and womens
I want to reading email message by C#
and as you know the c# dont apply the pop3 protocol
so I used The Tcp class to connect and reading message from the server
But the problem is when I try to read the message ,it read all the content of the message
as Message Id and some html tages
so
How can I read The Body Or Subject only
because I want to use form to Show From ,To,Subject,Body only so how
and thanks so so so so so much
|
|
|
|
|
Such email message is a file containing:
- a header
- a blank line
- the body (in ascii, can be empty)
- followed with 0 or more attachments
Rfc 822 descibes this and http://www.ietf.org/rfc/rfc2045.txt?number=2045[^] descibes the attachments (also read 2046,2047,2048)
Because many people use an email-client that produces a html-version of the body, these messages will have an ASCII-version in the body and the html-version as an (hidden) attachment. Sometimes the body is empty and there's only an attachment.
Hope this answers your question.
|
|
|
|
|
My apologies if something like this has already been asked and answered; I did some Google searching, as well searching on this site, and didn't find it, so here goes. I'm new to the world of .NET 3.5 and Linq. What I have are 1 + n xml files. The first Xml file looks sort of like this:
<files>
<file id="1" name="(some guid)"/>
<file id="2" name="(some guid)"/>
</files>
There are then files in the same directory, whose name matches the guid plus .xml, like so:
<file id="1">
<prop1>Value 1</prop1>
<prop1>Value 1</prop1>
<prop1>Value 1</prop1>
</file>
What I'd like to be able to do is this: for each file listed in the first xml blob, I want to create an object based on the values in each of the other xml files that look like the 2nd blob, and return that as an IEnumerable<Thing>. Does anybody know where I can find an example of how to do this?
Thanks in advance.
|
|
|
|
|
Greetings
I want to build a windows application that can connect to a webserver to get user authentication. Just like any IM msngr. We install the windows application and later it connects to internet to get authentication. How can I make such application???
Plz help.
modified on Wednesday, January 20, 2010 2:06 PM
|
|
|
|
|
Can anyone tell me why when writing code to open a file you use a forward slash in the path name instead of a back slash as in the following:
private void button1_Click(object sender, EventArgs e)
{
string file_name = "C:/test1.txt";
System.IO.StreamReader objReader;
objReader = new System.IO.StreamReader(file_name);
textBox1.Text = objReader.ReadToEnd();
objReader.Close();
}
|
|
|
|
|
Because it's easy to type!
In this case the slash ("/") and backslash ("\") are both understood as the delimiter for path, so either one should work. However, backslash is used to escape in string literals, so to use backslash, you should escape it, like so: \\. You can see that is more typing than using just slash.
If you have a lot of backslashes in your string literal, you can put @ in front of it so you don't need to escape them. For example,
string file_name = @"C:\test1.txt";
Still, there is the character @ you have to type. It's still more typing than simply using the forward slash.
|
|
|
|
|
Thanks
|
|
|
|
|
My guess is that it's simply a cheat to avoid having to type the requisite double backslash (special character):
string file_name = "C:\\test1.txt";
...Byte conservation; it's one byte shorter in the source file.
|
|
|
|
|
Thanks That's the problem with using tutorials...nobody around to answer the howcomes.
|
|
|
|
|
Darrall wrote: string file_name = "C:/test1.txt";
Because it works . It transforms into "C:\\test1.txt";
But I don't. I use either
@"C:\test1.txt";
"C:\\test1.txt";
|
|
|
|
|
Thanks
|
|
|
|
|
Reading this article might give you some more information.
Now...bring me that horizon. And really bad eggs...Drink up me hearties, YO HO!
|
|
|
|
|
|
Hi all
In my program i want to get image from users and insert it into mydatabase .
Now i want to know how can i insert image into database?
Thx alot for your attention.
|
|
|
|
|
You can conduct a search on "blob and database". An image can be treated as a blob (binary large object). Database tables can have blob fields. They can be used to hold images.
|
|
|
|
|
Thx for your reply.
I can't understand your answer.
I want to insert an image to sql server database.
How can i do it?
|
|
|
|
|
|
Hi!
I am trying to deploy the application on Windows CE 6.0 platform. However, when it comes to connection to SQL Server on my laptop it "thinks" for a while and I receive the following error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Windows.Forms.dll
Additional information: SqlException
I tried to find out the root of the problem and found out that my code
static string connectionString = "Data Source=192.168.2.132; Initial Catalog=MDetectorDatabase; Integrated Security=true";
private void SubmitButton_Click(object sender, EventArgs e)
{
string login = this.loginTextBox.Text;
string passw = this.passwTextBox.Text;
string user = "";
SqlConnection loginConnection = new SqlConnection(connectionString);
string loginquery = "SELECT * FROM Doctors Where UserName='" + login + "';";
SqlCommand loginCommand = new SqlCommand(loginquery, loginConnection);
loginConnection.Open();
SqlDataReader loginReader = loginCommand.ExecuteReader();
...
}
broke on loginConnection.Open(); line showing the problem 'loginConnection.ServerVersion' threw an exception of type System.InvalidOperationException'
Does anybody know how to fix this problem?
|
|
|
|
|
Hello all,
I am having a problem when trying to load a dataset with xml using ReadXml or ReadXmlSchema methods. The error I get is "DataSet doesn't allow the circular reference in the ComplexType named 'EDElementType'". The xml is below.
I think it is due to the fact that the complex type EDElementType contains a element named 'children' of type EDElementType which would cause a 'circular reference'. Any ideas how I can fix this?
Thanks in advance.
Xml:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cbe="http://www.abccorp.com/cbe" targetNamespace="http://www.abccorp.com/cbe" version="1.0.1" elementFormDefault="qualified">
<xsd:complexType name="CBEType">
<xsd:sequence>
<xsd:element name="edElements" type="cbe:EDElementType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="CBE" type="cbe:CBEType" />
<xsd:complexType name="EDElementType">
<xsd:sequence>
<xsd:choice>
<xsd:element name="values" minOccurs="1" maxOccurs="unbounded">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1024"></xsd:maxLength>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="hexValue" type="xsd:hexBinary" minOccurs="1" maxOccurs="1" />
</xsd:choice>
<xsd:element name="children" type="cbe:EDElementType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
|
|
|
|
|
I like going the reverse direction when creating a Data Set for use with MS tools. Ie, create a data set in code using the object methods to assign types and relationships and then save the Data Set to an XML file. You will then have a sample Data Set that MS will support.
|
|
|
|
|
I ended up using xsd.exe, which worked. Go figure.
|
|
|
|