473,729 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help -- Problem with redrawing UserControl

Hi,

I am using C# 2.0 (VS2005) to build my user control that contains a
number of dynamically loaded ListViews. ListViewItems have their
ForeColor properties set to either black or blue to distinguish
between ListViewItems.

As long as no other application window (i.e. word or calculator, or
....) goes over my running form, ForeColor properties or each
ListViewItem stays black or blue as intended.

However, if another application window moves over my running form and
the ListViewItems, or if my form is maximized, the ListViewItems that
were covered by other window or invisible change their ForeColor to
black (ForeColor changes to black).

I use protected overloaded OnSizeChanged event to handle resizing my
user control as:
protected override void OnSizeChanged(E ventArg e)
{
base.OnSizeChan ged(e);

reloadUserContr ol();
}

This event calls first base.OnSizeChan ged(e) event, then handles
redrawing and reloading of my user control. I have not identified any
other problems except this one.

Any Help Will Be Appreciated,
_dino_
Jan 11 '06 #1
7 2459
Dino,

What exactly does the reloadUserContr ol() do? If you have a bunch of
controls sitting on your user control and they have been loaded with data,
why would they need to be reloaded when the size of the control is changed?
I would imagine the ListViews have to loaded at some point, but OnSizeChange
seems a little odd to me. Furthermore, unless you have overridden the
OnPaint methods of the ListView controls themselves, their should be no
reason for the ForeColor to change to something other than what you setup at
design time or changed on the fly at runtime. Are these custom ListView
controls sitting on your user control?

Dave
"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:jh******** *************** *********@4ax.c om...
Hi,

I am using C# 2.0 (VS2005) to build my user control that contains a
number of dynamically loaded ListViews. ListViewItems have their
ForeColor properties set to either black or blue to distinguish
between ListViewItems.

As long as no other application window (i.e. word or calculator, or
...) goes over my running form, ForeColor properties or each
ListViewItem stays black or blue as intended.

However, if another application window moves over my running form and
the ListViewItems, or if my form is maximized, the ListViewItems that
were covered by other window or invisible change their ForeColor to
black (ForeColor changes to black).

I use protected overloaded OnSizeChanged event to handle resizing my
user control as:
protected override void OnSizeChanged(E ventArg e)
{
base.OnSizeChan ged(e);

reloadUserContr ol();
}

This event calls first base.OnSizeChan ged(e) event, then handles
redrawing and reloading of my user control. I have not identified any
other problems except this one.

Any Help Will Be Appreciated,
_dino_

Jan 12 '06 #2

Hi Dave,

The dynamically loaded ListView controls are just regular ListView
controls and I have not overloaded any of their methods. My user
control (it is a custom built panel that behaves properly in any other
situation so far) act as a container to these ListVew controls.

reloadUserContr ol() reloads my custom panel with ListViews and
repopulate the ListVeiws each time my form (and therefore my panel)
resizes to accomodate more or less ListView controls. That is why I
call realoadUserCont rols() each time I resize. That seams to be
working well.

The problem is when I drag another window over my form. When I do
that, my ListViews dissaper shortly, then shows up again as I drag the
window over my form. However, when they show up again, the Font and
ForeColor of ListViewItems have changed.

Similarily, when I maximaze my form, the ListViews that were visible
while the form was in its original size have Font and ForeColor as
desired. However, the ListViews that were not loaded before
Form.Maximize do not.

The custom panel I have build simply display a number of ListViews one
above another. Each ListView has only 2 ListViewItems (in detail
view). As the hight of my user control grows, it is reloaded to
accomodate more ListViews and vice versa.

+--------------------------------------------------------+
| Panel holding ListVeiws |
| +--------------------------------------------------+ |
| | - - ListView1 with 2 ListVewItems- - - - - - - | |
| +--------------------------------------------------+ |
| +--------------------------------------------------+ |
| | - - ListView2 with 2 ListVewItems- - - - - - | |
| +--------------------------------------------------+ |
| etc ... |

Please ask if this is not clear. I think that resizing is not the
problem since it works just fine.

Thank you,
_dino_

On Thu, 12 Jan 2006 11:06:39 -0600, "D. Yates" <fo****@hotmail .com>
wrote:
Dino,

What exactly does the reloadUserContr ol() do? If you have a bunch of
controls sitting on your user control and they have been loaded with data,
why would they need to be reloaded when the size of the control is changed?
I would imagine the ListViews have to loaded at some point, but OnSizeChange
seems a little odd to me. Furthermore, unless you have overridden the
OnPaint methods of the ListView controls themselves, their should be no
reason for the ForeColor to change to something other than what you setup at
design time or changed on the fly at runtime. Are these custom ListView
controls sitting on your user control?

Dave
"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:jh******* *************** **********@4ax. com...
Hi,

I am using C# 2.0 (VS2005) to build my user control that contains a
number of dynamically loaded ListViews. ListViewItems have their
ForeColor properties set to either black or blue to distinguish
between ListViewItems.

As long as no other application window (i.e. word or calculator, or
...) goes over my running form, ForeColor properties or each
ListViewItem stays black or blue as intended.

However, if another application window moves over my running form and
the ListViewItems, or if my form is maximized, the ListViewItems that
were covered by other window or invisible change their ForeColor to
black (ForeColor changes to black).

I use protected overloaded OnSizeChanged event to handle resizing my
user control as:
protected override void OnSizeChanged(E ventArg e)
{
base.OnSizeChan ged(e);

reloadUserContr ol();
}

This event calls first base.OnSizeChan ged(e) event, then handles
redrawing and reloading of my user control. I have not identified any
other problems except this one.

Any Help Will Be Appreciated,
_dino_


Jan 12 '06 #3
.... another interesting thing ... if I drag a window ower my form
slowly, Fonts and ForeColor redraw correctly, if I do this fast, they
dont ???!!!???

On Thu, 12 Jan 2006 11:06:39 -0600, "D. Yates" <fo****@hotmail .com>
wrote:
Dino,

What exactly does the reloadUserContr ol() do? If you have a bunch of
controls sitting on your user control and they have been loaded with data,
why would they need to be reloaded when the size of the control is changed?
I would imagine the ListViews have to loaded at some point, but OnSizeChange
seems a little odd to me. Furthermore, unless you have overridden the
OnPaint methods of the ListView controls themselves, their should be no
reason for the ForeColor to change to something other than what you setup at
design time or changed on the fly at runtime. Are these custom ListView
controls sitting on your user control?

Dave
"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:jh******* *************** **********@4ax. com...
Hi,

I am using C# 2.0 (VS2005) to build my user control that contains a
number of dynamically loaded ListViews. ListViewItems have their
ForeColor properties set to either black or blue to distinguish
between ListViewItems.

As long as no other application window (i.e. word or calculator, or
...) goes over my running form, ForeColor properties or each
ListViewItem stays black or blue as intended.

However, if another application window moves over my running form and
the ListViewItems, or if my form is maximized, the ListViewItems that
were covered by other window or invisible change their ForeColor to
black (ForeColor changes to black).

I use protected overloaded OnSizeChanged event to handle resizing my
user control as:
protected override void OnSizeChanged(E ventArg e)
{
base.OnSizeChan ged(e);

reloadUserContr ol();
}

This event calls first base.OnSizeChan ged(e) event, then handles
redrawing and reloading of my user control. I have not identified any
other problems except this one.

Any Help Will Be Appreciated,
_dino_


Jan 12 '06 #4
Dino,

Sorry, I tried to adding new listviews with varying colors to a user control
on the fly at runtime, but I'm having no luck reproducing the problem that
your seeing. If I had to guess where your issue is, I would probably point
to the reloadUserContr ol() routine. The only other suggestion that I have
is to not use a "user control" as your container. Just create your ListView
controls in a panel that is sitting on the form itself since your creating
the ListView on the fly anyway.

Dave
Jan 13 '06 #5

Hi Dave,

I am using a custom built panel on my user control. That panel gets
dynamically loaded with ListViews. Somehow, the controls take
ForeColor and Font properties of their container (my custom panel)
when a window is dragged over my form (and the user control).

I am sure the problem is in my OnPaint of my custom panel. How is it
possible to make the container repaint all its controls when another
window is dragged over them? What I am missing in my OnPaint? How
does regular Panel handles this?

Thank you,
_dino_

On Fri, 13 Jan 2006 10:09:20 -0600, "D. Yates" <fo****@hotmail .com>
wrote:
Dino,

Sorry, I tried to adding new listviews with varying colors to a user control
on the fly at runtime, but I'm having no luck reproducing the problem that
your seeing. If I had to guess where your issue is, I would probably point
to the reloadUserContr ol() routine. The only other suggestion that I have
is to not use a "user control" as your container. Just create your ListView
controls in a panel that is sitting on the form itself since your creating
the ListView on the fly anyway.

Dave


Jan 13 '06 #6
For those interested, I have found out that this is rather an IDE
issue than coding issue. When I run my application from IDE, this
repainting problem occurs, when I run it from compiled .exe, the
problem is gone.

_dino_

On Wed, 11 Jan 2006 22:23:41 GMT, Dino Buljubasic
<di**@noplaceli kehome.com> wrote:
Hi,

I am using C# 2.0 (VS2005) to build my user control that contains a
number of dynamically loaded ListViews. ListViewItems have their
ForeColor properties set to either black or blue to distinguish
between ListViewItems.

As long as no other application window (i.e. word or calculator, or
...) goes over my running form, ForeColor properties or each
ListViewItem stays black or blue as intended.

However, if another application window moves over my running form and
the ListViewItems, or if my form is maximized, the ListViewItems that
were covered by other window or invisible change their ForeColor to
black (ForeColor changes to black).

I use protected overloaded OnSizeChanged event to handle resizing my
user control as:
protected override void OnSizeChanged(E ventArg e)
{
base.OnSizeChan ged(e);

reloadUserContr ol();
}

This event calls first base.OnSizeChan ged(e) event, then handles
redrawing and reloading of my user control. I have not identified any
other problems except this one.

Any Help Will Be Appreciated,
_dino_


Jan 23 '06 #7
Dino,

I'm reading through your email and wondering why you have overridden the
OnPaint method of your user control. Since the user control is covered by a
panel, which you fill with ListViews, the OnPaint method is basically doing
what? It's the same as covering a form with a panel and overriding the
form's OnPaint method...anythi ng you "paint" will not be shown since the
panel is covering the form. Furthermore, you shouldn't have to "refresh"
the ListView controls. Once their added to the panel, they should act the
same way they would if you had added it to a form. So, what exactly do you
have in your OnPaint method of your custom USER control?

If none of this helps, try moving the problem outside of your current
application. For example, create a brand new windows application, add a
panel to the form, and copy all your logic for adding ListViews to the panel
to the new windows application. This will eliminate the use of a custom
control and may provide some insight into what's going on with your original
application.
Hope I'm helping and not making your life worse....

Later,
Dave

"Dino Buljubasic" <di**@noplaceli kehome.com> wrote in message
news:jl******** *************** *********@4ax.c om...

Hi Dave,

I am using a custom built panel on my user control. That panel gets
dynamically loaded with ListViews. Somehow, the controls take
ForeColor and Font properties of their container (my custom panel)
when a window is dragged over my form (and the user control).

I am sure the problem is in my OnPaint of my custom panel. How is it
possible to make the container repaint all its controls when another
window is dragged over them? What I am missing in my OnPaint? How
does regular Panel handles this?

Thank you,
_dino_

On Fri, 13 Jan 2006 10:09:20 -0600, "D. Yates" <fo****@hotmail .com>
wrote:
Dino,

Sorry, I tried to adding new listviews with varying colors to a user
control
on the fly at runtime, but I'm having no luck reproducing the problem that
your seeing. If I had to guess where your issue is, I would probably
point
to the reloadUserContr ol() routine. The only other suggestion that I have
is to not use a "user control" as your container. Just create your
ListView
controls in a panel that is sitting on the form itself since your creating
the ListView on the fly anyway.

Dave

Jan 24 '06 #8

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

Similar topics

0
3427
by: Otie | last post by:
I have a circle that displays information in 1-degree increments - there are 90 such increments that comprise the circle. I need a pointer within the circle that rotates. The pointer must include areas to the left and right of the center line so that a person is better able to see when something is within 2 or 3 or 4 or 5 marks (degrees) of its neighbors. I can use a line and get it to rotate - that is no problem. The problem is drawing an...
2
2200
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol rounded.... ***************************************************** Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim x1 As Integer = 0 Dim x2 As Integer = Me.ClientSize.Width Dim iHeight As Int32 = Me.Height Dim...
2
3023
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
2
1249
by: Lau Lei Cheong | last post by:
Hello, I'm writing a usercontrol that contains a property named "disabled". It is set to false by default but there is also another button in the usercontrol that'll set it to true. On the main form a number of them are displayed. During the On_Load event, 1) It'll check to see if the usercontrol is disabled. If true, the row containing the usercontrol is hidden.
5
3591
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
16
3257
by: Merlin | last post by:
I have created a users control with a text box and button on it, what I want to do is override the usercontrol Keydown events with that of the Text box. What is the correct syntax to accomplish this? Example of my text box sub:- Private Sub Edit_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Edit.KeyDown End Sub Thanks
22
2349
by: Colin McGuire | last post by:
I apologize for posting yet another scrollbar question. Here is my code. All I want is for a diagonal line to appear from coordinates (0,0) to (width,height) in a usercontrol regardless of whether the user autoscrolls the usercontrol (other things that are on the usercontrol I want to scroll, but haven't included any here). Here are the steps to reproduce my problem. 1. Launch Visual Studio and create a new Windows application with...
1
3021
by: Philipp Lenz | last post by:
I'm very confused about how this works, all the tutorials out there show me how to apply a skin to a webcontrol, but I want to know how I can access the components of a control....for example: I have a usercontrol, the ascx is defined like this: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Test.ascx.cs" Inherits="Spin.Test" %> <asp:Panel ID="Panel1" runat="server" Height="243px" Width="350px">
4
2940
by: Sugan | last post by:
Hi all, I've created a Custom button control and i'm drawing the graphics for the button when the paint event is fired. I used Invalidate method to redraw the graphics in events like mousemove, click etc. My problem is as follows: I created a test application to test the created custom button control. I had two buttons on the form. When i click on one button 1 a message box is showed. This message box covers one part of the other...
0
8921
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8763
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
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
9202
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,...
1
6722
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
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
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.