Click here to Skip to main content
13,295,051 members (85,084 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 6-Aug-12 10:22am
How about the form loaded event?
pieterjann 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 6-Aug-12 10:44am
Give you an example? Go through the events list in the designer and select it from the list.
__John_ 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.
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.
Your question is "who"? Not quite a valid one... :-)
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_ 6-Aug-12 10:29am
It might work but it stinks.
DaveyM69 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.
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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2017
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