Communicate between two windows forms in C#

Form1 triggers Form2 to open. Form2 has overloaded constructor which takes calling form as argument and provides its reference to Form2 members. This solves the communication problem. For example I’ve exposed Label Property as public in Form1 which is modified in Form2. With this approach you can do communication in different ways. Download Link for … Read more

Use of Application.DoEvents()

Hmya, the enduring mystique of DoEvents(). There’s been an enormous amount of backlash against it, but nobody ever really explains why it is “bad”. The same kind of wisdom as “don’t mutate a struct”. Erm, why does the runtime and the language supports mutating a struct if that’s so bad? Same reason: you shoot yourself … Read more

Using non-literal strings in different methods in C#

Fine, here you go. Passing the textbox values as arguments in the parameter. public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); txtName.Text = “Your name”; tbxAge.Text = “Your age”; tbxDinner.Text = “Your dinner”; OutputNewValues(txtName.Text, tbxAge.Text, tbxDinner.Text); } private void OutputNewValues(string name, string age, string dinner) { string answer = “Hello, ” … Read more

C# Sql Textbox Select

You didn’t give any info about the problem you have so I assume the thing you forgot is adding the required ‘s around the from.Text and to.Text in your select command. Also, you should use Date validation to validate if the given text is a date. DateTime dtfrom; DateTime dtto; if(DateTime.TryParse(from.Text,out dtfrom) && DateTime.Parse(to.Text,out dtto);) … Read more