Click here to Skip to main content
14,972,394 members

Comments by Tony Hill (Top 19 by date)

Tony Hill 16-Jun-21 15:14pm View
   
If you want help with this it would be helpful to post your code here so we can examine it to find your problem.

Remember we cannot see your screen or read your mind, help us to help you by showing the code.
Tony Hill 4-Jun-21 12:51pm View
   
Form2 has two public events called 'form2Opened' and 'form2Closed', other forms can ask
to be notified when these events are raised.

I will only discuss the 'form2Opened' to not complicate matters.

In the Form1 Load event handler method Form1 registers an interest in being notified when
either of these events are raised and the method which should be called when the event is raised.

In the Form1 'Form1_Load' method we create Form2 and register an interest in the 'form2Opened' event and display the Form2.

private void Form1_Load(object sender, EventArgs e)
{
...
...
...
form2 = new Form2();
form2.form2Opened += Form2HasOpened; // (1)
form2.ShowDialog();
}

After the call to ShowDialog() in the Form1 'Form1_Load' method the 'Form2_Load' method
executes, the first thing that happens is Form2 checks to see if anything is listening
to the Form2 form2Opened event by testing to see if it is null or not, if it is not null
the form2Opened event is invoked to notify Form1 that Form2 has loaded.

private void Form2_Load(object sender, EventArgs e)
{
if (form2Opened != null)
{
form2Opened.Invoke(this, new EventArgs()); // This will notify Form1 that Form2 has opened and that Form1
// should execute the Form1.Form2HasOpened method.
}
}

Control will now be passed to the Form1.Form2HasOpened method (see (1) above) and the code in the
method is executed which in the example will tell Form1 to hide itself with Hide() method,

private void Form2HasOpened(object sender, EventArgs e)
{
Hide();
}

After the Form1.Form2HasOpened method has finished executing control is returned
to Form2.Form2_Load method where the event was invoked.

Much the same sort of thing happens with 'form2Closed' event but you should be able
work it out yourself.
Tony Hill 23-May-21 15:04pm View
   
Richard, Did you see the sneaky spam link under the Korean text.
Tony Hill 23-May-21 14:40pm View
   
Deleted
Can you see the sneaky spam link under the Korean text.
Tony Hill 23-May-21 6:17am View
   
As Richard said this question was answered nine years and your solution is vulnerable to SQL injection attacks.
Tony Hill 14-Apr-21 7:35am View
   
It should be placed on its own line after the last line of your code.
Tony Hill 11-Apr-21 5:33am View
   
I have modified the code in my example, next time you ask a question try and make the intent more clear so others can understand your problem.
Tony Hill 30-Mar-21 11:55am View
   
Only 7 years late with an answer which does not answer the OP's question, the OP actually wants to focus (highlight) a newly created node in the treeview not focus a control.
Tony Hill 28-Mar-21 7:52am View
   
Well spotted Patrice T, I knew the maths was wrong but did not spot the lack of a return.
Tony Hill 14-Feb-21 14:27pm View
   
Do you really think it a good idea to show how to create sql injection vulnerabilities in sql statements
Tony Hill 26-Jan-21 6:36am View
   
Seems you have done it again
Tony Hill 29-Dec-20 5:44am View
   
This is just a copy of the first sentence of solution 1.
Tony Hill 10-Dec-20 9:54am View
   
Thanks
Tony Hill 18-Nov-20 14:59pm View
   
Completely unrelated nonsense to the original posters question.
Tony Hill 18-Jul-20 12:37pm View
   
Unlikely that the original poster is still interested as the question is 5 years old.
Tony Hill 14-May-20 6:05am View
   
This problem was solved by the original poster 9 years.
Tony Hill 11-May-20 14:44pm View
   
Apart from answering a 10 year old question you did not answer the OP's question about how to do it in SQL not c#
Tony Hill 8-Mar-20 16:07pm View
   
Yes but your CupMethod calls the BrewMethod with one argument as doesCupMethod, WaterMethod, SizeMethod, LidMethod.

You have to fix it in all those methods as well.
Tony Hill 2-Apr-18 10:57am View
   
This is Android Java not C++.