Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Events
I'm programming a program that opens a second window and directly prints it. I thought I could use the event Form_Load. But if i print the form at that stage it will become totaly black (I think because the form has not finished loading yet). So I need a trigger to print the page directly after it is loaded, and this trigger can not be user input.
Who can help me on calling my print function when the page is loaded?
Posted 6-Aug-12 5:15am
Wes Aday at 6-Aug-12 10:22am
How about the form loaded event?
pieterjann at 6-Aug-12 10:27am
is there a form Load AND a form Loaded event? if so could you give me an example of the form Loaded? My printing function makes an image of the form and prints that. As the form is not completely loaded at the form Load event it returns a black page....
Wes Aday at 6-Aug-12 10:44am
Give you an example? Go through the events list in the designer and select it from the list.
__John_ at 6-Aug-12 10:28am
Could you call your Print function from the form that owns the one you want to print?
Otherwise I think you might need to overide OnPaint.
Sergey Alexandrovich Kryukov at 6-Aug-12 12:13pm
Makes no much sense to speculate before OP creates some code sample and show how to reproduce the problem. And I voted 1 for "Solution 1", which is pure evil.
Sergey Alexandrovich Kryukov at 6-Aug-12 12:05pm
Your question is "who"? Not quite a valid one... :-)
Sergey Alexandrovich Kryukov at 6-Aug-12 12:12pm
The approach to the problem is simple: you should write a code sample, as simple and short as possible, to reproduce the problem. Then, if you still would not come to a solution, post it with your question, using "Improve question". By the way, "Load" is a "fake" event, it simply invoked right after a constructor is called, so using it cannot solve any problems; with equal success, you can call some method from your constructor, at the very end.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Final answer:
Add a timer and disable it after the tic.

Thread closed
__John_ at 6-Aug-12 10:29am
It might work but it stinks.
DaveyM69 at 6-Aug-12 10:42am
This will work only if the form loads before the timer ticks which is not guaranteed - a poor solution in my opinion.
There are several events raised by the form itself that may suffice (such as Shown) that would be more appropriate.
Sergey Alexandrovich Kryukov at 6-Aug-12 12:08pm
Very, very bad idea. It does not solve anything; and it totally pointless. Using timers is generally bad, but here it does not have any reason at all. And if it apparently "solves" the problem, it could be even worse: the original problem is hidden, the reasons are not understood, and you would just close the way to understand it -- very nice. You got very deserved 1, but this is not a main thing here. I would like to help you with the advice: your approaches to solving the problems will get you into trouble. Don't do such things.
pieterjann at 7-Aug-12 8:16am
Ok so you say do not do this. I tried with the event Shown, but it is not activated :( I will search a bit more before I ask you guys to solve my problem :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Abhinav S 155
1 Mika Wendelius 151
2 Sergey Alexandrovich Kryukov 135
3 TheRealSteveJudge 114
4 Peter Leow 110
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,442

Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100