471,310 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 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 2282
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by paul meaney | last post: by
2 posts views Thread by Lau Lei Cheong | last post: by
5 posts views Thread by serge calderara | last post: by
16 posts views Thread by Merlin | last post: by
1 post views Thread by Philipp Lenz | last post: by
reply views Thread by rosydwin | last post: by

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.