.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Form application with Panel and PictureBox controls: Panel.Clear() does NOT clean. (in C#)

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :Windows Application

I have been developing a Windows Form application with a Panel and many PictureBox controls. PictureBox controls are created dynamically in the Panel control. The initial display works fine, say with 100 PictureBoxes in the Panel control. Then, the Panel control is cleared by "this.panel.CLear()", for the next display, say new 50 images in the PictureBoxes.

The current situation is that the second display (with new 50 images) seem to be completed AFTER the first 100 images, although the first 100 images are cleaned. This means that the first area where the first 100 images displayed is blank, and the new 50 images are displayed after the blank/white area.

My question is how to display the new images at the beginning of the Panel control.


View Complete Post

More Related Resource Links

Remotely access winform application through admin panel

I am going to develop following application but not sure how to do this   Application will run different instances for various clients on different servers.     Each instance will run on different criteria stored in database managed by an admin.     Would like to be able to run this from the admin section.     Maybe using a server command line component and pipin the output into a web based admin? -- Whatever you think is best.     This application will run basically 24-7   Any best solution, idea etc

AJAX update panel and update progress controls

I have writtena Crystal reports web application, that prompts ths user for parameters and then apply them and exports the report to a folder as .rpt and then display the report. I prompt the parameters on one screen and then display the report on another page. I have the AJAX update panel and update progress controls in the parameter page. When the user enters the parameters and click on ok, I export the report and then loads the report to a session report document and transfer the user to the second page where the report is displayed. I use the following code to do transfer to the seconds page. I have excluded the report load and parameter assign code here.rpt.ExportToDisk(ExportFormatType.CrystalReport, "c:\reports\testrep.rpt") Session("rpt") = New ReportDocument Session("rpt").load("c:\reports\testrep.rpt") Response.Redirect("show.aspx") In the second page I have the following: rptViewer.reportsource = Session("rpt") My problem is this works one time and then stops working the second. What I found out was it comes to the statement: Response.Redirect("show.aspx") But it does not even load the show.aspx page. It stays on the parameter page. There are no errors displayed. I could not see any errors when I debug the application also. And out of the blue it works

Arranging Panel controls in a FlowLayoutPanel at runtime?

I have a 10 Panels with visibility FALSE for ALL inside the FlowLayoutPanel. I set the visibility of the Panel at runtime. The problem is that, the order in which the Panel appears different for each & every time when i retrieve the value from db. Because based on the value from db i set the Order of Panel at runtime by making the Panel's visibility to TRUE. At First, when i retrieve the value i am getting the output in proper order same as by value from db. But when the value changes again the Panel is to auto adjust based on the current order from db. But its not appearing for the 2nd time. What i need to do?? Pls Help  Regards TurbulentGeek "Mark as answer if it helped you..."

Custom panel - missing design time support for controls.

I’m trying to implement a custom panel, one that will behave kind of like the standard Canvas panel. The implementation is done and it is working when I add components in the xaml, but what is not working is move and resize of components in the designer. In the designer each component shows the ‘selected frame’ when selected, but it cannot be moved or resized. Can someone point me to what I’m missing, or an article that describes how do add this support?.   The reason I’m not deriving from the existing Canvas is mainly because I want to understand how it works and how to implement it manually.   Thanks  

Center a picturebox in a screeen sized panel

I am placing (in code) a Picturebox inside a panel.  The Dock property of the panel is Fill to fil.  The picturebox is set to a fixed size and the image to Zoom.  I want the picturebox to appear in the dead center of the screen, but it always appears centered vertically, but all the way on the left side of the screen.  Nothing I do will move it horizontally into the center.  Not sure what i am doing wrong. pictureBox1 = new PictureBox(); pictureBox1.Size = new System.Drawing.Size(1024, 1024); pictureBox1.MaximumSize = new System.Drawing.Size(1024, 1024); pictureBox1.BackColor = System.Drawing.Color.Gray; pictureBox1.Dock = DockStyle.None; pictureBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.BorderStyle = BorderStyle.None; panel1.Controls.Add(pictureBox1);

Modal Popup controls & Update panel

Dear frnds, I have a Modal Popup controls on the page. This will display some data.     It takes around 10 min to fetch the data to display on the popup control.     Code for displaying the popup control is on page behind.   So problem is that it takes 10 min to come up the popup. No indication till them on the page . All the controls are inside the update panel   Regards, Sajid P K  

Trouble with update panel and dynamic controls and post back


 I have a page that is mostly dynamically built in the page load of my VB.net code behind page.

The issue is that I made a change to the page and added a button that redirects to a secondary page. When the button is clicked there is a very noticeable lag until the button click event fires because the page is being rebuilt every time.

I had not wrapped the code in the load event in the If not ispostback.... because I have dynamic controls that the user interacts with and I need the page to be rebuilt when the user clicks them.

The dynamic controls are clickable table cells. I did some looking and I found that the RegisterPostBackControl. I thought this would be perfect but, it does not although I maybe using it incorrectly.

Here is the code flow.

Page Load

If not ispostback then


end if


private sub setuppage()

'get a reference to the scriptmanager on the master page

Dim scriptManager = DirectCast

Resizing Panel when adding controls


I have a panel on a form and I am adding controls to it from code behind.

Code behind:
First I am creating TableLayoutPanel
in loop I am adding controls to TableLayoutPanel
and then adding TableLayoutPanel to panel.

problem is I have specified panel height = 100 in designer. how to make it grow when more rows (controls) added to TableLayoutPanel?

At the same time I want to move controls below the Panel to move down..

| Panel		  |  --> I want to make this auto size
| Other Control1  |
| Other Control2  |
| Other Control3  |
| Other Control3  |

I tried setting Autosize=true for Panel and it didn't help!!

Removing Controls from a Panel (Not the Usual Question)


If I remove controls from a panel using

For Each ctl as control in Panel.Controls

then after removing the control I can ctl = Nothing or ctl.dispose (I can never recall if there is a difference).

But the For Each approach has the problem which has been covered here so often.


If I use another technique, e.g. Controls.Clear or a For i as Integer = 0 to Controls.Count - 1

then how can I dispose the control or set it to Nothing.  (Which maybe doesn't matter but I'm trying to be a very good citizen.)  I assume that I should not dispose the controls or set them to Nothing before removing them.  Right?

Thanks,  Bob

Some Controls like master Page in Windows Form application???

hi , i have a form , panel , tool bar and search text Box , and i want to make them like a master page ( its not asp.net projects ) its windowsform application , when user clik to some thing the the contetnplace holder change but the master page content dont change .
 its possible?

example ur web browser , at the top u see tool bars , navigation bar ,,,, etc , and down u see web page , how ?

Problems with Repeater Control, Update Panel and the Toolkit controls


Hi Guys,


Having a bit of an issue with the Toolkit controls.

I have a Repeater Control nested inside the Update panel, the repeater item template contains a multiview control allowing users to flick through seperate bits of information. This was working fine the async update was perfect, no issues.

I have then decided to include the rating control to one of the views. problem is now everytime i want to change the view it causes the whole page to postback.  

Attached is the code.

Any help is much appreciated

Inheriting Form Panel not working


When I inherit from PictureBox I can display my new Object on form, but when I use the same code to inherit from Panel, I don't see anything on the form when I add an object. My code looks something like this. It works fine for PictureBox, but not Panel. What Am I doing wrong.

    public class MyObject : Panel 
        public MyObject()

        private void InitializeComponent()

            this.BackColor = System.Drawing.Color.Red;
            this.Name = "ImagePanel";
            this.Size = new System.Drawing.Size(65, 70);
            this.Visible = true;

In main I created a form control and instatiate myObject and add to the form controls like this

Scroll/Zoom Windows.Forms.Panel controls


Is there some "thumbnail" or other "easy" way to provide the ability to have a populated panel of UserControl derived objects and scrollbar "move" them and "middle mouse zoom" them on the Client area of the panel?

I am using net FrameWork 4.0  The documentation leaves a tantilizing trail and I sure it can be done, but I do not want to miss something so simple like using the Thumbnail/bitmap/Background properties or methods of the Panel control? 

Thanks Everyone



all basic windows controls,wpf controls,silverlight application

here you will find all the information from basic.

Cutting Edge: Context-Sensitive PictureBox Controls


Great ideas are timeless. A long time ago in Microsoft Systems Journal Paul DiLascia demonstrated a neat trick to display context-sensitive tooltips floating over pictures. As the user moved the mouse over the picture, the tooltip control updated its text to reflect the name of the pointed figure.

Dino Esposito

MSDN Magazine July 2006

ASP.NET: Develop Polished Web Form Controls the Easy Way with the .NET Framework


Pre-built custom controls make application design easier and faster and allow you to maintain UI consistency. However, prepackaged controls can be big and slow, and are OS-specific. For those who don't want to use prepackaged controls, Visual Studio .NET provides controls for Web Forms similar to those found in Windows Forms, including label and textbox, and new additions such as the DataGrid, all of which you can customize. If you want to design your own controls, the .NET Framework provides inheritable classes that take care of all the nasty stuff you want to avoid, including page lifecycle, maintaining state across invocations, and browser detection. This article discusses these concepts, as well as eventing, rendering, and client-side scripting.

David S. Platt

MSDN Magazine June 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend