473,241 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

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(EventArg e)
{
base.OnSizeChanged(e);

reloadUserControl();
}

This event calls first base.OnSizeChanged(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 2420
Dino,

What exactly does the reloadUserControl() 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**@noplacelikehome.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(EventArg e)
{
base.OnSizeChanged(e);

reloadUserControl();
}

This event calls first base.OnSizeChanged(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.

reloadUserControl() 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 realoadUserControls() 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 reloadUserControl() 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**@noplacelikehome.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(EventArg e)
{
base.OnSizeChanged(e);

reloadUserControl();
}

This event calls first base.OnSizeChanged(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 reloadUserControl() 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**@noplacelikehome.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(EventArg e)
{
base.OnSizeChanged(e);

reloadUserControl();
}

This event calls first base.OnSizeChanged(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 reloadUserControl() 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 reloadUserControl() 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**@noplacelikehome.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(EventArg e)
{
base.OnSizeChanged(e);

reloadUserControl();
}

This event calls first base.OnSizeChanged(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...anything 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**@noplacelikehome.com> wrote in message
news:jl********************************@4ax.com...

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 reloadUserControl() 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
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...
2
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...
2
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...
2
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...
5
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...
16
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...
22
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...
1
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...
4
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,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.