473,795 Members | 3,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refresh UserControl drawing elements

Hi you all,

I have created a usercontrol with a filledEllipses on a
filledRectangle , using this Paint event:

private void myControl_Paint (object sender,
System.Windows. Forms.PaintEven tArgs e)
{
SolidBrush aBrush = new SolidBrush(this .BackColor);
e.Graphics.Fill Rectangle(aBrus h, 10,10, this.Width - 10, this.Height
- 10);
if(m_fOn)
aBrush.Color = m_cOn;
else
aBrush.Color = m_cOff;
e.Graphics.Fill Ellipse(aBrush, 20, 20, this.Width - 20, this.Width -
20);
aBrush.Dispose( );
}

using a Timer I switch m_fOn form true to false and back like this

private void myTimer_Tick(ob ject sender, System.EventArg s e)
{
m_fOn = ! m_fOn;
this.Refresh();
}

Now the control is completly redrown.

For testing I have set the myTimer.interva l to 10, and created a
testing application.
I discovered that the memory used by the testing application is
constand increasing.
So I would like to repaint the FillEllipse only.

Any advice on this?

Thanks in advance..

Executor

May 13 '06 #1
1 7199
Yes you are right because timer is constantly refreshing the control no
matter from is visible or not or form is minimized or not. I think you dont
need to refresh your control when your form is minimized or when its not
visible at all. So what you can do is if the form is visible (this.Visible =
True) and then invalidate the form.
The Invalidates method invalidates a specific region of the control and
causes a paint message to be sent to the control. It will cause the Paint
event of the control to fire and in paint event call ReDraw function of this
control.

"Executor" wrote:
Hi you all,

I have created a usercontrol with a filledEllipses on a
filledRectangle , using this Paint event:

private void myControl_Paint (object sender,
System.Windows. Forms.PaintEven tArgs e)
{
SolidBrush aBrush = new SolidBrush(this .BackColor);
e.Graphics.Fill Rectangle(aBrus h, 10,10, this.Width - 10, this.Height
- 10);
if(m_fOn)
aBrush.Color = m_cOn;
else
aBrush.Color = m_cOff;
e.Graphics.Fill Ellipse(aBrush, 20, 20, this.Width - 20, this.Width -
20);
aBrush.Dispose( );
}

using a Timer I switch m_fOn form true to false and back like this

private void myTimer_Tick(ob ject sender, System.EventArg s e)
{
m_fOn = ! m_fOn;
this.Refresh();
}

Now the control is completly redrown.

For testing I have set the myTimer.interva l to 10, and created a
testing application.
I discovered that the memory used by the testing application is
constand increasing.
So I would like to repaint the FillEllipse only.

Any advice on this?

Thanks in advance..

Executor

May 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4027
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the same way a menu does. To do this my control needs to get notified when the user tried to click off of it. The Leave and LostFocus events of the UserControl work most of the time but not always. For example, if they click on a part of the form...
17
8544
by: SamSpade | last post by:
picDocument is a picturebox When I do picDocument.Invalidate() the box paints. But if instead I do picDocument.Refresh() the box does not paint. What does Refresh do. I guessed it did an Invalidate and an Update. Can someone shed some light?
0
2473
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls which are not behaving as I would expect. Specifically, if there is a command button external to the usercontrol which is activated by a shortcut key (eg Alt-B), the command button Click event handler code 'executes' even though the textbox set...
0
2441
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that article and recreated the situation I see in my application. (Code included below.) If you run the...
2
5072
by: Steve | last post by:
This is a weird one. I have a series of "SmartParts" which are CAB (Composite Application Block) Views which are finally just UserControls (99% of the time) Anyway, I layout my UserControl in the VS2005 designer, but at runtime, the controls are in different locations and different sizes. I have been able to restore their sizes by putting a hack together that will set their sizes to the correct values in the UserControl's Resize...
6
12141
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is contained in and thus all other controls on the parent form. (I want various controls on the form to...
3
2040
by: Martin | last post by:
Hi ! I've developed a small UserControl with five textbox and label. However, when I want to display the UserControl in a form, controls appear slowly one after one. I've activated double buffering and removed all code in the OnLoad, constructor and I still have the same problem. Here is the code that I use to display the UserControl un the form _objContainer.SuspendLayout();
4
2470
by: Martin | last post by:
Hi everyone ! For those who haven't read my previous post, I have a problem with a UserControl. When I try to display it on a form, controls seem to appear one after one. In the following example, it's less visible because controls don't execute any code... Is someone has an idea of how I could solve this problem and also improve the method ShowUserControl. I try to figure out I could flicker effect when I press the button twice quickly.
1
3558
by: =?Utf-8?B?TmV3YnJv?= | last post by:
I have this program running on PDA compact framework in which it will receive paint message from server's networkstream and updates the client's screen by drawing on this custom 'Draw' userControl. Now on the PDA this 'Draw' userControl has a size of 480 x 320. This control is added to a panel with autoscroll set to true. Since the PDA screen has a size of 320 x 240, scroll will always be visible and show the left top sectionof the...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.