Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
i create a form dynamically in code and add a user control to it than i show the form
if i add a background image to the user control with stretch to the backgroundimagelayout the form will flashes after complete loading if i put none it does nothing and load correctly.


does anyone know how to solve it, i am looking to make the image size same as the screen size but it is not good way.

C#
Form f = new Form();
f.Size = SystemInformation.VirtualScreen.Size;
uc.Dock = DockStyle.Fill;
f.Controls.Add(uc);
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
f.TopMost = true;
f.Show();



thanks for anyhelp
Posted
Comments
Kenneth Haugland 15-Aug-12 15:23pm    
And what happens if you do this:
Form f = new Form();
f.Show();
Waleedkassem 15-Aug-12 21:23pm    
the problem after the form is shown it flashes for once and it is ok, as you refresh it.
Sergey Alexandrovich Kryukov 15-Aug-12 15:43pm    
System.Windows.Forms? Tag "Forms".
--SA
Sergey Alexandrovich Kryukov 15-Aug-12 15:45pm    
Not a question. You don't show where you create "uc", you don't show how this fragment of code is called. How do you know that it's called at all?
--SA
Waleedkassem 15-Aug-12 21:24pm    
only i instantiate a custom user control which has a background image and some controls on it.

1 solution

Well I had problems creating, communicating and opening new forms in c#.
I would recommend you design the form first, then create it on code and modificate its properties for a customize use. For the flashing problem (supposing it flashes and closes) I would depurate it and use form.ShowDialog() preventing it gets disposed before user decides it.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900