When you create a new Random number generator it is seeded against the current time. If the loop is very short there is no time for the clock to update, so it gets reseeded against the same time as the last iteration, therefore producing the same number again.
If you want to work with .NET 3.0, then you can easily change gradients and drawing styles of standard windows controls using WPF.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Assuming you're talking about WinForms here: There is a DesignMode property, which can be evaluated. Do note, however, that you cannot use the property in the designer - this is why I usually use OnLoad. Here's a sample, which also plays nicely with controls you're going to extend:
/// Inits the base class and registers event listeners.
/// <param name="e" />
protected override void OnLoad(EventArgs e)
/// An empty template method which is being invoked after the
/// control has been loaded during <see cref="OnLoad">.
/// <remarks>The base class does not invoke this method if
/// the control is in design mode.
protected virtual void InitControl()
//this method is supposed to be overridden. Initialization of
//the base class itself happens in InitControlInternal
I have two forms opened in my mdiparent form I want to pass the value from textbox of 1st form to textbox of the 2nd form I cannot create a new instance of the 2nd form since I want to send to the same opened instance, I tried by changing the property to public but cannot be acessed with out creating a new instace pls help me to pass the values to the same opened instance of the form
declare a variable as static ..........if this doenst works take a class declare static variables in it assing the values to the stat variable while u r in first form then use them in next form.......................please dont mind ...make u r question clear
Don't try passing values between forms. A neater architectural approach, is to abstract the data model from the actual visual representation of the value. One way to do this is to implement something called the Model View Controller[^] pattern.
Deja View - the feeling that you've seen this post before.
I have drawn the line (using DrawLine()) from point(10,10) to point(20,20). The center point of the line is (15,15). Suppose i Rotate At(10,10) the line for 30 degrees.
How to calculate the center point after rotating?
My name is Manoj kumar. I am facing a problem related with Tcp. I want to bring .txt file from remote computer using Tcp server. On remote maching a program is running which uses Tcp client to transfer the .txt file. The client port is 5003 and the ip address is 192.168.1.12.
Use a tcplistener to check for incomming connections.
After accepting a connection just send the content of the .txt file using ASCII or Unicode - encoding (there are Encoders in System.Text - namespace) over the accepted socket and close the connection.
On the client just use a TcpClient to connect to the server and use the class-methods to read all the stream, decode it with the same encoder you used (ASCII/Unicode/whatever) and you've got it.
I'm guessing it might have something to do with httpRequest not releasing resources after the first run, but am at a lost to know how to be sure. I'd appreciate it if someone could give me some pointers. Thanks
I have developed a Client-Server application using socket.When Client side application executes on another system an error occures(Only one usage of each socket address (protocol/network address/port) is normally permitted).But already a TcpListener application has been executed on that system .I need both application to be executed simultaneously.
I have a problem that connects to my database (on the same machine) using the usual c#/vs connectionString. When I publish it, that string is still the same (i.e. the name of the machine doesn't change). Yea, I think I've hardcoded the connectionString. But how can I softcode it using VS? How can I make it so that the connectionString takes the name of the current machine it is residing on or better, the application would prompt for where the database is.
Any help is appreciated? Or even just point me to articles.
Just use the app.config - file to set up your connection-strings.
It's easy to administrate and flexible (all you will need is a text-editor).
If this is not what you want, use a static connection string and use
to replace your computer name with the one you get from System.Net.Dns.GetHostName()
(I don't recommend this - normaly another DB will require another login etc.)
Last Visit: 14-Aug-20 17:00 Last Update: 14-Aug-20 17:00